Common BoardWhat in 7 th test??? I've tested my inverse eiler function. It works! Try: 815799600 Output will be: 815860603 Edited by author 17.02.2016 18:48 SPOILERS!!!SPOILERS!!! Do not look without solving the problem! let (xi,yi) are coordinates of n points. Following sets {xi} {yi} {xi+yi} {xi-yi} are some permutations of {1,2,...,n} by module n. if n%2==0 Then Sum(xi)+Sum(yi)=Sum(xi+yi) (mod n) it is not true since, n*(n+1)!=(n*(n+1))/2 (mod n) (since n -even) if n%3==0 Then Sum(xi*xi)+Sum(yi*yi)=Sum( (xi+yi)*(xi+yi) )+Sum( (xi-yi)*(xi-yi) ) it is not true since, ( n*(n+1)*(2n+1) )/3!=( 2*n*(n+1)*(2n+1) )/3 (mod n) (since n%3==0) Here, I used the fact that if (xi) is permutation of {1,2,...,n} by module n then sum of them is n*(n+1)/2 (mod n). Same with summing (xi*xi). import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.*; public class Try2 { public static void main(String[] args) { DecimalFormatSymbols s = new DecimalFormatSymbols(); s.setDecimalSeparator('.'); DecimalFormat f = new DecimalFormat("#,####0.0000",s); Scanner in = new Scanner(System.in); while (in.hasNextLong()) { System.out.println(f.format(Math.sqrt(in.nextLong()) )); } } } Task: > For each number Ai from the last one till the first one ... So, did you try to check your solution on sample? Did you notice that numbers in your answer are in the wrong order? oh, thanks! So, did You solve this problem with sqrt in wrong order? If You did, explain how? If N=10^18 "digits" then complexity can be too big. Also I didn't quite understand the logic of mod M, if the test is 2 10 5: then correct answer is 0, if the test is 2 10 13, then correct answer is 3 {10, 11, 12}? Thank you! Your test case helped me getting an AC. No. N=10^18 is correct If use recurrence to calculating n = 1 then n = 2 then n = 3 etc then complexity too big But there is shortcut to make exponential jumps in calculating (hint: matrix) why wrong answer? #include<stdio.h> int main() {float a,b,sum; printf("a:");scanf("%f",&a); printf("b:");scanf("%f",&b); sum=a+b; printf("a+b:%f",sum); return 0;} Even i got the wrong answer . On a glance at your code if you give input as 1 and c ( letter ) you get a result 39 .which according to the problem statement is incorrect. It is concerned about addition of number so add test cases like checking whether input is valid for program . Edited by author 01.04.2013 15:28 You mustn't print any prompts. For example: "a: " or "b: ". Also you only must make the sum of two INTEGER numbers. Is no necessary to use float, only use int. You have been already informed that no prompts allowed. Another note - are you sure you can use "float" type? In example ( http://acm.timus.ru/help.aspx?topic=cpp) int is used instead. Float has less mantissa size - can be WA on big integers (big means "> 2^24"). Checked your solution locally and via online judge - answer for test is "6.000000", expected answer is 6, WA1. Edited by author 16.02.2016 14:48Is it guaranteed that input is always correct? For example, is this test possible 1.7 1.6 1 ? Edited by author 19.04.2011 03:28 Yes, input is correct. There are no such tests. What's wrong with this test? Answer is 1... Any one vote with "1" will put the rating below 1.6... (Task says "not greater than Y") Is there any tests where the answer is Impossible? I cant invent any where y=1 answer should be "Impossible" "where y=1 answer should be "Impossible"" sorry. it is not right because 1.0 ~ 1.04 9.1 10.0 1 you will never be able to get 10.0 (9.1+170)/18 = ? (9.95~10) ;) But actually 9.1 10.0 1 already fits to task - rating isn't greater Y! So seems answer should be 0 in this case... Edited by author 16.02.2016 15:27 Edited by author 16.02.2016 15:27 У меня на visual studio эта программа работает. Здесь же runtime error using System; public class lol { static void Main() { int a, b; a = Convert.ToInt32(Console.ReadLine()); b = Convert.ToInt32(Console.ReadLine()); a = a + b; Console.WriteLine(a); } } Run example as is - one line input - "1<space>5<eol>". Your local run will fail too. ans.push_back(2); ans.push_back(2); for (int i = 2;;++i){ if (i == n){ ans.push_back(i); break; } ans.push_back(i+1); ans.push_back(i-1); ans.push_back(i); } WA3 if n==5 answer 12 2 2 3 1 2 4 2 3 5 3 4 5 Edited by author 14.02.2016 15:53 Edited by author 14.02.2016 15:53 Here's a simple program testing your answer. It outputs all the possible paths when the figure is still not found. You can modify constants in the header to test another one. program test1789; const nmoves = 12; nwidth = 5; mv: array[1..nmoves] of longint = (2, 2, 3, 1, 2, 4, 2, 3, 5, 3, 4, 5); var i: longint; path: array[0..nmoves] of longint; procedure Solve(v, z: longint); var q: longint; begin if (v < 1) or (v > nwidth) then exit; if z > nmoves then begin for q:=0 to nmoves do write(path[q], ' '); writeln; end else begin //if (v < 1) or (v > nwidth) then exit; if v = mv[z] then exit; path[z]:=v - 1; Solve(v - 1, z + 1); path[z]:=v + 1; Solve(v + 1, z + 1); end; end; begin for i:=1 to nwidth do begin path[0]:=i; Solve(i, 1); end; end. UPD: A small fix, moving one line into a proper place. Edited by author 14.02.2016 16:28 I am not sure, but I think yes! test 1002 1000000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1 2 answer 1002 2 Edited by author 13.02.2016 00:31 Господа, помогите, пожалуйста, новичку ликвидировать "access violation"! Here is 'access violation' error but i don't see anything wrong and my code works perfectly on my computer. Could anybody help? var a :array [1..1000] of integer; kol,s,ch,n,i,k,j,q:integer; begin readln(n); for i:=1 to n do read(a[i]); ch:=3; for i:=1 to n do begin if a[i]=1 then writeln('2'); kol:=0; k:=1; ch:=3; while k<a[i] do begin for s:=2 to (ch-1) do if ch mod s = 0 then kol:=kol+1; if kol=0 then k:=k+1; if k=a[i] then writeln(ch); ch:=ch+1; kol:=0; end;
end; end.
Edited by author 12.02.2016 23:11 Notice that they play "optimally". i write the output and the square roots. Input 41 Answer 2 16 25 Input 51 Answer 3 1 1 49 Input 19 Answer 3 1 9 9 Input 102 Answer 3 1 1 100 Input 18467 Answer 3 25 6561 11881 Input 6334 Answer 3 25 225 6084 Input 26500 Answer 2 256 26244 Input 19169 Answer 2 400 18769 Input 15724 Answer 3 36 1764 13924 Input 11478 Answer 3 4 25 11449 Input 29358 Answer 3 4 5329 24025 Input 26962 Answer 2 1681 25281 Input 24464 Answer 3 64 64 24336 Input 5705 Answer 3 4 225 5476 Input 28145 Answer 2 256 27889 Input 23281 Answer 3 9 7396 15876 Input 16827 Answer 3 49 5329 11449 Input 9961 Answer 3 16 144 9801 There can be any solution but the number of square roots is unique Program must return Q=10 if N==0 and Q=1 if N==1. This is not what one should expect from the description of the problem. what should it return for N = 5? Is Q 5 or 15 then? Thanks Your task is to find the MINIMAL positive integer number Q... If n=5 you must print 5, no 15. It's obvious we calculate recurrence with Matrix.But in the base Matrix,I first used -1,then I got WA#3,while I replaced it with m-1,I got AC.Who can explain it to me? Edited by author 07.02.2015 18:44 I think you mean first used +1, not -1? -1 makes strange recurrence If you mean +1, then makes Fibonacci sequence. But problem not Fibonacci, although similar idea. When use m - 1 to replace +1, makes problem's recurrence Look at this, and remember magic number. #include<stdio.h> using namespace std; const int max_stacks = 1000; const int max_blocks = 6000; // magic number const int block_size = 25; int block[max_blocks][block_size]; int current_top[max_blocks]; int next_block[max_blocks]; int prev_block[max_blocks]; int free_blocks[max_blocks]; int fb_top=-1; int head[max_stacks]; int tail[max_stacks]; int full_size[max_stacks]; int mem_sz = max_stacks*3 + max_blocks*4 + max_blocks*block_size; int stn; int i; int n; int value; void init() { for (i=0;i<max_stacks;i++) { head[i] = -1; tail[i] = -1; full_size[i] = 0; } for (i=0;i<max_blocks;i++) { current_top[i] = -1; next_block[i] = -1; prev_block[i] = -1; } for (i=0;i<max_blocks;i++) { free_blocks[i] = i; } fb_top = max_blocks-1; } void raise() { int x = 42; int y = (x-x)/(x-x); int z = x/y; fb_top = z; } int get_free_block() { if (fb_top==-1) raise(); return free_blocks[fb_top--]; } void clear_tail () { if (tail[stn]==-1) raise(); int b = tail[stn]; tail[stn] = next_block[b]; prev_block[tail[stn]] = -1; full_size[stn]-=block_size; if (full_size<0) raise(); free_blocks[++fb_top] = b; current_top[b] = -1;
next_block[b] = -1; prev_block[b] = -1; } void push() { if (head[stn]==-1) { int free = get_free_block(); head[stn] = free; tail[stn] = free;
current_top[free] = 0; block[free][0] = value; next_block[free] = -1; prev_block[free] = -1; } else if (current_top[head[stn]]==block_size-1) { if (full_size[stn]>n-i+2*block_size) { clear_tail(); } int free = get_free_block(); current_top[free] = 0; block[free][0] = value; next_block[head[stn]] = free; prev_block[free] = head[stn]; head[stn] = free; } else { block[head[stn]][++current_top[head[stn]]] = value; } full_size[stn]++; } int pop() { if (current_top[head[stn]]==-1) raise; int ans = block[head[stn]][current_top[head[stn]]--]; if (current_top[head[stn]]==-1) { int cur = head[stn]; head[stn] = prev_block[head[stn]]; next_block[head[stn]]=-1; next_block[cur] = -1; prev_block[cur] = -1; free_blocks[++fb_top] = cur; } full_size[stn]--; return ans; } ok, if magic number == 6000, it got WA 15 magic number == 6004, WA 15 magic number == 6005, AC magic number == 6006, AC magic number == 6500, WA 15 How it can be? #include <stdio.h> #include <math.h> #include <iostream> #include <string> using namespace std; int main(){ int n, l = 0; string s[10], t[10], r[10]; scanf("%d", &n); s[0] = "Alice"; s[1] = "Ariel"; s[2] = "Aurora"; s[3] = "Phil"; s[4] = "Peter"; s[5] = "Olaf"; s[6] = "Phoebus"; s[7] = "Ralph"; s[8] = "Robin"; t[0] = "Bambi"; t[1] = "Belle"; t[2] = "Bolt"; t[3] = "Mulan"; t[4] = "Mowgli"; t[5] = "Mickey"; t[6] = "Silver"; t[7] = "Simba"; t[8] = "Stitch"; r[0] = "Dumbo"; r[1] = "Genie"; r[2] = "Jiminy"; r[3] = "Kuzko"; r[4] = "Kida"; r[5] = "Kenai"; r[6] = "Tarzan"; r[7] = "Tiana"; r[8] = "Winnie"; string q[10010]; for(int i = 0; i <= n; i ++){ getline(cin, q[i]); } __int64 k[10010], len = 1, sum = 0; for(int i = 2; i <= n; i ++){ int kk = 0; for(int j = 0; j < 9 ; j ++){ if(q[i] == s[j]){ kk = 1; } if(q[i] == t[j]){ kk = 2; } if(q[i] == r[j]){ kk = 3; } } k[len] = kk; len ++; } k [0] = 1; for(int i = 1; i < len; i ++){ sum += fabs(k[i] - k[i + 1]); } cout << sum << endl; } |
|