Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Test 6 | Shorekh | 1131. Copying | 9 Feb 2018 04:11 | 2 | Test 6 Shorekh 20 Oct 2016 22:48 Whoever gets Wrong Answer at 6th test, try to change your way of finding the power of two. My solution got WA#6 when I calculated power of two this way: power = ceil(log(x)/log(2)); Better calculate it by multiplying it. | | what about Ramanujan's 1729 | Adkham | 1349. Farm | 8 Feb 2018 19:27 | 1 | I remember once going to see him when he was ill at Putney. I had ridden in taxi cab number 1729 and remarked that the number seemed to me rather a dull one, and that I hoped it was not an unfavourable omen. "No," he replied, "it is a very interesting number; it is the smallest number expressible as the sum of two cubes in two different ways." G.H.Hardy 1729 = 1^3 + 12^3 = 9^3 + 10^3 | | what is wrong with my code ??? | Adkham | 1110. Power | 8 Feb 2018 02:23 | 1 | #include<iostream> #include<cmath> using namespace std; int func(int k, int n, int m) { if(n == 0) return 1; else return func(k, n-1, m)*k%m; } int main() { int n, m, y, x, i = 0; int b; bool flag = true; cin >> n >> m >> y; if((n >0 && n < 999) && (m > 1 && m < 999) && (0 < y && < 999)) { while(i < m) { x = func(n, i, m); if(x == y) { cout << i << ' '; flag = false; } i++; } if(flag) cout << "-1"; } else cout << "-1"; return 0; } Edited by author 08.02.2018 02:25 Edited by author 08.02.2018 02:27 | | Solution is pretty easy | Gilles Deleuze | 1109. Conference | 7 Feb 2018 21:51 | 1 | Firstly, the problem asks to find number of edges in minimum edge cover Secondly, the number of such edges plus the number of maximum matching equals to number of vertices, that is N + M Thirdly, you can find the number of max. matching easily with dfs-like algorithm (you can find code online). The answer is N + M - (number of max. matching) | | what is the 30 test | Bekzat | 1820. Ural Steaks | 6 Feb 2018 23:31 | 3 | | | TLE #21 | JohnDarkman | 2102. Michael and Cryptography | 6 Feb 2018 19:25 | 1 | TLE #21 JohnDarkman 6 Feb 2018 19:25 I get TLE on 21 test. What can you advise? | | Example Testcase | Khanhhuy_19 | 2018. The Debut Album | 6 Feb 2018 18:47 | 2 | i think 212 in the Example test is wrong cause we have 2 remix of "I miss you" when the most remix that we can reach is 1 . Edited by author 21.01.2018 23:56 It says: "in a row". It means that there can be any number of remixes of each song, the most important part it that the number in each row doesn't;t have to exceed a for 1st and b for 2nd | | Test | BdE | 1846. GCD 2010 | 5 Feb 2018 22:15 | 1 | Test BdE 5 Feb 2018 22:15 in: 9 + 10 + 10 + 10 - 10 - 10 + 5 - 10 - 5 + 123 out: 10 10 10 10 10 5 5 1 123 GL. Sqrt decomposition works fine in this problem. | | as of Feb 2018, what is test #4? | LordPhantom | 1120. Sum of Sequential Numbers | 3 Feb 2018 01:39 | 1 | N = int(input()) if N == 1: print(1,1) exit() for P in range(round(N**0.5)+1,0,-1): A = (2*N - P**2 + P) / (2*P) if A % 1 == 0: print(int(A),P) exit() | | Hint | Al.Cash | 1661. Dodecahedron | 2 Feb 2018 19:44 | 2 | Hint Al.Cash 3 May 2009 14:37 This problem isn't hard! Just use Burnside's lemma. Re: Hint Gilles Deleuze 2 Feb 2018 19:44 One would need Polya enumeration theorem to obtain an explicit formula though. Well, the theorem is a generalization of Burnside's anyway. | | Why dont work?C# | Artem | 1068. Sum | 2 Feb 2018 13:12 | 1 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication25 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()), Sum=0; if (Math.Abs(N)<10000) { while (N != 1) { if (N > 1) { Sum = Sum + N; N--; } else { Sum = Sum + N; N++; } } } Console.WriteLine(Sum+1); } } } | | Runtime error - Test 2 | Valentina | 1987. Nested Segments | 31 Jan 2018 23:23 | 1 | I've got Runtime error in Test 2. I've written the code in Java. Could anybody share the test case for the Test2? | | I have WA 36 | arrammis | 1854. Negotiations with Parthians | 30 Jan 2018 05:02 | 2 | My solution pass's all tests presented here in the forum. But i get WA at 36 test, authors please help what's there???? <code> #include <iostream> using namespace std; int main() { __int64 n, i, a, b, c, maxC1 = 1, maxC2 = 1, maxC = 1; cin >> n; for (i = 1; i*i < 1000000; i += 2) { if (n % i == 0) { a = n/i; b = sqrtl((long double)a); c = sqrtl((long double)i); if (b*b == a && a > maxC1) { maxC1 = a; } if (c*c == i && i > maxC2) { maxC2 = i; } maxC = max(maxC1, maxC2); } } cout << maxC; return 0; } </code> Do I need to write own sqrt ? What the problem is ? Edited by author 22.01.2015 17:54 For test 36, make sure to use unsigned long longs to prevent overflow: 999999998000000001 999999998000000001 | | Where difference? | __Andrewy__ | 1191. Catch the thief! | 30 Jan 2018 01:05 | 1 | #include <iostream> using namespace std; const int kmax=105; int K[kmax]; int L,n; int R(int x, int y) { if(x%y==0) return x/y; else return x/y+1; } int main() { cin>>L>>n; for(int i=1;i<=n;i++) cin>>K[i];
if(n==1) { if(L<K[1]) cout<<"YES"; else cout<<"NO"; return 0; }
int t1=R(L, K[1])*K[1], t2=K[1]; if(t1==t2) t1+=K[1];
for(int i=2;i<=n;i++) { t2+=K[i]; if(t1<t2) { cout<<"YES"; return 0; } t1=t2+R(t1-t2,K[i])*K[i]; if(t1==t2) t1+=K[i]; }
cout<<"NO"; return 0; } and #include <iostream> using namespace std; const int kmax=105; int K[kmax]; int L,n; int main() { cin>>L>>n; for(int i=1;i<=n;i++) cin>>K[i];
if(n==1) { if(L<K[1]) cout<<"YES"; else cout<<"NO"; return 0; }
int t1=(L/K[1]+1)*K[1], t2=K[1];
for(int i=2;i<=n;i++) { t2+=K[i]; if(t1<t2) { cout<<"YES"; return 0; } t1=t2+(1+(t1-t2)/K[i])*K[i]; }
cout<<"NO"; return 0; } ????????????????????????????????????????????? | | The sequence | Gilles Deleuze | 1490. Fire Circle | 30 Jan 2018 00:02 | 2 | How to compactly encode this sequence (or delta with ceil(round(x)))? | | I do not understand this Test please explain to me | Axmadjon | 1918. Titan Ruins: Artful Manipulations | 29 Jan 2018 00:28 | 2 | HINT: you must read problem on english version. Перевод на русский язык плох. Нифига непонятно, о чём речь в 4 пункте. А вот в английской версии всё зашибись. Суть в следующем. Есть n рычагов, каждый рычаг можно поставить ровно в одно из n состояний. Изначально есть 1 монета. Пусть на некотором шаге имеется i монет (1<=i<=n). Если ничего не делать, то со временем станет i-1, i-2, ... , 1 монет. Можно применить зарядку (в любой момент). Пусть при применении зарядки i рычаг находится в состоянии j (1<=j<=n). Тогда число монет становится j. Нужно найти все такие состояния рычагов (т.е. вектор (x1,...,xn) : 1<=xi<=n), что с помощью использования некоторых зарядок можно получить n монет. Примеры: 1)n=2 все возможные комбинации: (1,1) (1,2) (2,1) (2,2) получить 2 можно 2 способами: (2,1) и (2,2) - в этом случае сразу получаем 2 монеты почему не подходят (1,1) и (1,2)? в этом случае снова станет 1 монета
2)n=4 комбинации из ответа: (4,*,*,*) -> кол-во=4*4*4 (3,4,1,*) -> кол-во=4 (3,4,2,*) -> кол-во=4 (3,4,3,*) -> кол-во=4 (3,*,4,*) -> кол-во=4*4 (2,3,4,*) -> кол-во=4 (2,4,*,*) -> кол-во=4*4 ответ=112 почему (3,4,2,*) даёт решение? Число монет меняется так:вначале 1 монета. Если не делать зарядку, то 1 монета так и будет. Если применить зарядку, то станет 3 монеты. Далее если не делать зарядку, то станет 2 монеты: потом можно сделать зарядку и получить 4 монеты либо не делать зарядку и получить 1 монету; если сделать зарядку, то получим 2 монеты: потом если не делать зарядку,то получим 1 монету, а если сделать зарядку, то получим 4 монеты. Edited by author 29.01.2018 00:31 | | Can you check out what's wrong here ? (c++) | Said707 | 1083. Factorials!!! | 28 Jan 2018 23:08 | 1 | #include <bits/stdc++.h> using namespace std; int main(){ int n, sana,s; char k[21]; cin>>n; cin.getline(k,sizeof(k)); sana = strlen(k)-1; if (1<=n&&n<=10&&1<=sana&&sana<=20){ if(n%sana==0) { s=sana;} else { s=1;} while(n>0){ s*=n; n=n-sana;} cout << s << endl; } } Edited by author 28.01.2018 23:09 | | I got Accepted using this approach | Shen Yang | 1672. Droid flies | 28 Jan 2018 18:16 | 3 | divide three euler angle into 50 pieces each of them is 2*pi/50;enum each euler angles and compute minmimum max different of distance to three faces. for(alpha=0;alpha<=2*pi;alpha+=dtheta) { if(min_dist>compute(alpha)) { min_dist=compute(alpha); ch=alpha; } } low=ch-dtheta; high=ch+dtheta; then ternary search [low,high].. Do you understand? Can it be solved using QR-decomposition? | | Crash (access violation) #2! Help! I'm not understand! | PSYCHO | 1008. Image Encoding | 28 Jan 2018 10:12 | 2 | program Project2; {$APPTYPE CONSOLE} uses SysUtils; var a:array [0..110,0..110] of integer; d:array [0..2000] of string; k:array[0..2000,1..2] of integer; x1,y1,x,y,i,sc,l,j,n,f,b1,c1:integer; puk:string; procedure ar (b,c,m:integer); var res:string; begin res:=''; k[m,1]:=b; k[m,2]:=c; if a[b+1,c]=1 then begin a[b+1,c]:=0; res:=res+'R' end; if a[b,c+1]=1 then begin a[b,c+1]:=0; res:=res+'T' end; if a[b-1,c]=1 then begin a[b-1,c]:=0; res:=res+'L' end; if a[b,c-1]=1 then begin a[b,c-1]:=0; res:=res+'B' end; d[m]:=res; end; begin readln (n); for i:= 0 to 11 do for j:= 0 to 11 do a[i,j]:=0; read (x1); readln (y1); a[x1,y1]:=0; writeln (x1,' ',y1); for i:= 2 to n do begin read (x); readln (y); a[x,y]:=1; end; f:=1; sc:=1; ar(x1,y1,f); repeat b1:=k[sc,1];c1:=k[sc,2]; puk:=d[sc]; l:=length(puk); if l>0 then for i:= 1 to l do begin case puk[i] of 'R': begin f:=f+1; ar(b1+1,c1,f); end; 'T': begin f:=f+1; ar(b1,c1+1,f); end; 'L': begin f:=f+1; ar(b1-1,c1,f); end; 'B': begin f:=f+1; ar(b1,c1-1,f); end; end; end; inc(sc) until sc=n; if f>1 then for i:= 1 to f-1 do writeln (d[i],','); writeln (d[f],'.') end. Program work ideally on my computer. | | If you have WA#1, look here. | William Lam | 1008. Image Encoding | 28 Jan 2018 09:51 | 2 | If you are getting WA#1, try this. Input: 8 1 1 1 2 1 3 2 1 2 3 3 1 3 2 3 3 Output: 1 1 RT, R, T, T, R, T, , . |
|
|