Общий форумДля теста 5 5 что нужно вывести 0 2 5 5 или 0 1 5 "An employee can send a memo only to another employee. The route of memo can consist of one employee." So the answer should be 0 1 5. A can't understand what's the problem and why I don't pass it. Help me, please. What's the meaning of the question ? I tried to get it but in vain, even the test unclear for me I'll explain the test. 6 2 5 3 4 1 9 The first one is chosen as current candidate, and has 2 disadvantages. Then, he is compared with 2nd pirate (5 disadvantages), 3rd (3), 4th (4), 5th (1). When comparing with 5th pirate, we see that he has less disadvantages (1) than current candidate (2). So he becomes the current candidate. And then we finally compare him with last pirate (9 disadvantages). In the end, 1st pirate with 2 disadvantages was compared to 2nd, 3rd, 4th, 5th — compared 4 times; 2nd pirate with 5 disadvantages was compared to 1st — compared 1 times; 3rd pirate with 3 disadvantages was compared to 1st — compared 1 times; 4th pirate with 4 disadvantages was compared to 1st — compared 1 times; 5th pirate with 1 disadvantages was compared to 1st, 6th — compared 2 times; 6th pirate with 9 disadvantages was compared to 5th — compared 1 times; Out of all the pirates, the 1st one has the most compare times — 4. Thus, we output 1 — the index of a pirate who was compared most times. But, if several pirates were compared the same amount of times — say, if 5th one was also compared 4 times (if there were 2 more pirates in input) — then both answers "1" or "4" would be correct in this case. Is this any clearer? thanks I want to know what's the task of this problem. There is an interesting way to code it. For each piece we can have a function like this: pair<string, int> get_king(int n, int x0, int y0) { int cnt = 0; for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <= 1; dy++) if (dx != 0 || dy != 0) { int x = x0 + dx; int y = y0 + dy; cnt += (x >= 1 && x <= n && y >= 1 && y <= n); } return { "King", cnt }; } In the main code we just do the following loop: for (auto get : { get_king, get_knight, get_bishop, get_rook, get_queen }) { auto res = get(n, x, y); cout << res.first << ": " << res.second << endl; } After that the function for queen look very easy: pair<string, int> get_queen(int n, int x0, int y0) { int cnt = get_rook(n, x0, y0).second + get_bishop(n, x0, y0).second; return { "Queen", cnt }; } If you have any ideas on how to code it better, please write them here :) My tests (N, Array, Answer): [8, '6 7 9 13 18 24 31 50', 0], [5, '5 5 4 3 3', 0], [5, '3 3 4 5 5', 0], [1, '1', 1], [1, '2', 2], [6, '1 4 5 6 7 9', 0], [5, '5 8 13 27 14', 3], [5, '5 4 3 3 3', 0], [5, '11 10 8 7 6', 0], [6, '1 4 5 6 7 9', 0], [6, '9 7 6 5 4 1', 0], [7, '1 2 3 4 5 6 6', 1], [3, '1 1 5', 3], [6, '1 2 3 4 100 100', 0], [5, '5 8 13 14 15', 1], [5, '4 6 6 7 9', 0], [7, '36 25 12 10 8 7 1', 1], [6, '101 51 51 3 2 2', 0], [6, '1 4 5 6 7 9', 0], [4, '1 3 9 27', 14], [6, '6 6 5 4 3 2', 0], [20, '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20', 0] All tests = True. What I do wrong? Edited by author 17.11.2016 19:27 Edited by author 17.11.2016 20:03 What does it mean? For example if K = 10, N = 3, M = 112 correct numbers are 101 102 103 104 105 106 107 108 109 110 111 Is it right? Thanks. Edited by author 17.11.2016 18:22 WA8 - all options are off and <10fps WA12 - "Perfect" when >=60fps, NOT >60fps Tags: geometry *hint hint* using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { int N = Convert.ToInt32(Console.ReadLine()); int A = Convert.ToInt32(Console.ReadLine()); int B = Convert.ToInt32(Console.ReadLine()); if (N >= 1 && 100 >= N) if (A >= 1 && 100 >= A) if (B >= 1 && 100 >= B) { Console.WriteLine(N * A * B * 2); } } } } 1) Here is task fragment: "The only line contains integers...." You are reading 3 lines. 2) if (N) if (A) if (B) {...} - else what? Any difference how exactly your program fail in "else" case? I think you should skip parameters check or fail in some specific way - visible and different from regular mistake. Edited by author 16.11.2016 16:53 if consider the position of player there are about 7.5*10^8(upper_bound),state, we can come up some idea to compact the states,and use a huge array instead of hash_table to prevent the duplication of states this may far speed up your program Edited by author 15.11.2016 13:02 Edited by author 15.11.2016 13:02 maybe for every 3*10^7 possible states,we can compact the postion of player and record the number of connected place,and use twice bfs search I think that will reduce the number of states we must store... I have been stuck on this test 2 for a while now. I gave up then came back, but still don't know what I need to change. Here is my solution, I used 'sieve of eratosthenes' to get out the primes. Please help me out. Should I change my input range for array. #include <iostream> #include <math.h> using namespace std; int main() { __int64 n; cin >> n; __int64 *input_list = new __int64[n]; //__int64 *primes = new __int64[15000]; long int primes[20000] = { 0 };
// input the numbers for (int i = 0; i < n; i++) { cin >> input_list[i]; } // Let A be an array of Boolean values, indexed by integers 2 to n, //initially all set to true. //for i = 2, 3, 4, ..., not exceeding √n: //if A[i] is true: //for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n : //A[j] := false
//Output: all i such that A[i] is true. long int a[20000] = { 0 };
for (long int i = 2; i <= 20000; i++) { if (a[i] == 0) { for (long int j = i * i, c=1; j < 20000; j +=i, c++) { a[j] = 1; } } //cout << a[i] << ends; } for (long int i = 2, p=0; i <= 20000; i++) { if (a[i] == 0) { //cout << i << ends; primes[p] = i; p++; } else { continue; } } for (int i = 0; i < n; i++) cout << primes[input_list[i] - 1] << endl; return 0; } Edited by author 15.11.2016 09:33 For a test 5 2260 2261 2262 2263 2264 your program gives 19991 19993 19997 0 0. I tried an "obvious" fix, changing all 20000's into 200000's, to fit for 1 15000 test, but got a stack overflow error. I don't want to look too deep into it, so i'd rather suggest going an easy way. Just make IsPrime(int value), which would determine if the number is prime or not, then for i=1..infinity, add i into your array if it's prime, and stop after adding 15000 numbers. After that it should be easy. I was bit confused to obtain accepted. I applied my solution to test straightforward approach and obtain TLE but i'm not. With next example i would defenitely obtain TLE: 50 50 00000000000000000000000001111111111111111111111111 00000000000000000000000011111111111111111111111111 00000000000000000000000111111111111111111111111111 00000000000000000000001111111111111111111111111111 00000000000000000000011111111111111111111111111111 00000000000000000000111111111111111111111111111111 00000000000000000001111111111111111111111111111111 00000000000000000011111111111111111111111111111111 00000000000000000111111111111111111111111111111111 00000000000000001111111111111111111111111111111111 00000000000000011111111111111111111111111111111111 00000000000000111111111111111111111111111111111111 00000000000001111111111111111111111111111111111111 00000000000011111111111111111111111111111111111111 00000000000111111111111111111111111111111111111111 00000000001111111111111111111111111111111111111111 00000000011111111111111111111111111111111111111111 00000000111111111111111111111111111111111111111111 00000001111111111111111111111111111111111111111111 00000011111111111111111111111111111111111111111111 00000111111111111111111111111111111111111111111111 00001111111111111111111111111111111111111111111111 00011111111111111111111111111111111111111111111111 00111111111111111111111111111111111111111111111111 01111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111110 11111111111111111111111111111111111111111111111100 11111111111111111111111111111111111111111111111000 11111111111111111111111111111111111111111111110000 11111111111111111111111111111111111111111111100000 11111111111111111111111111111111111111111111000000 11111111111111111111111111111111111111111110000000 11111111111111111111111111111111111111111100000000 11111111111111111111111111111111111111111000000000 11111111111111111111111111111111111111110000000000 11111111111111111111111111111111111111100000000000 11111111111111111111111111111111111111000000000000 11111111111111111111111111111111111110000000000000 11111111111111111111111111111111111100000000000000 11111111111111111111111111111111111000000000000000 11111111111111111111111111111111110000000000000000 11111111111111111111111111111111100000000000000000 11111111111111111111111111111111000000000000000000 11111111111111111111111111111110000000000000000000 11111111111111111111111111111100000000000000000000 11111111111111111111111111111000000000000000000000 11111111111111111111111111110000000000000000000000 11111111111111111111111111100000000000000000000000 rejudge me please, I also get AC using brute_force and can't pass this test case Edited by author 15.11.2016 07:21 now 13 problems with 10W+ rating... #include<iostream> #include<iomanip> #include<cmath> using namespace std; int main() { long long n,i=0,c=0; double a[100001]; while(cin>>n){ a[i]=sqrt(n); i++; c++; } for(int i=c-1; i>=0; i--) cout<<fixed<<setprecision(4)<<a[i]<<endl; system("pause"); return 0; } The size of the input stream does not exceed 256K Could somebody who solved this problem send some examples of tests and solutions? I thought that I wrote a correct algorithm, that summarise number of stones of each type, then sort it and then check how many permutations of the last one that makes it equal to K, there is and calculate a number of possibilities. But I get error on Test 3. Or may be I did not understood the task, I found the bug, but now I get wrong answer for test 26 Finally solved it. The last bug was to find a function that calculates factorial coefficients (ncr) without going to big numbers. What is the principle of this function? Anybody can help me with TEST #10. Just give me an example Thank you very much. 222 ans is--> -1 bcuz 222/6= 37 ;but 37 is prime so ans -1 #include <iostream> long int a,b,c,d,e,f,n,z,x,a1,a2; using namespace std; void main() { cin >>a; n=a%10; f=a%100; f=f/10; e=a%1000; e=e/100; d=a%10000; d=d/1000; c=a%100000; c=c/10000; b=a%1000000; b=b/100000; if ((n==9)||(f==9)||(e==9)) { z=(e+f+n)+1%10; } else { z=e+f+n; } if ((d==9)||(c==9)) { x=(b+c+d)+1%10; } else { x=b+c+d; } a1=z-x; a2=x-z; if ((a1==1)||(a2==1)) { cout <<"Yes"; } else { cout <<"No"; } } 4 0 0 1 0 0 1 -1 1 0.7071 3 0 0 1 0 0 1 0.6436 3 -1 0 1 0 0 1 0.9102 Thank you. But... C:\Casual\Task1058>task1058.exe <test12.txt 0.7071 C:\Casual\Task1058>task1058.exe <test13.txt 0.6436 C:\Casual\Task1058>task1058.exe <test14.txt 0.9102 I can hardly ever understand anything. My program cannot pass test #3. Test#1 3 3 1 2 3 ans:27 Test#2 2 6 1 3 ans:36 Test#3 3 6 3 4 5 ans: 180 Test#4 1 5 3 ans:5 Test#5 1 2 1 ans:1 Test#6 3 2 1 2 2 ans:4 |
|