| Show all threads Hide all threads Show all messages Hide all messages |
| C语言AC | xinxin | 1725. Sold Out! | 9 Oct 2016 18:30 | 1 |
C语言AC xinxin 9 Oct 2016 18:30 #include "stdio.h" int main() { int n,i; scanf("%d %d",&n,&i); if(n==2) {printf("0"); return 0; } if(i<=n/2) printf("%d",n-i-2); else printf("%d",i-1-2); } |
| test 10......sad.... | xinxin | 1688. Team.GOV! | 9 Oct 2016 16:25 | 1 |
#include "stdio.h" #include "stdlib.h" #include<string.h> int main() { long int m,n,sum=0,a[3001]; scanf("%ld %ld",&n,&m); for(int i=1;i<=m;i++) { scanf("%d",&a[i]); } n=n*3; for(int i=1;i<=m;i++) { sum+=a[i]; if(sum>=n) { printf("Free after %d times.",i); return 0; } } printf("Team.GOV!"); } |
| test 11 ......sad.... | xinxin | 1283. Dwarf | 8 Oct 2016 19:08 | 1 |
#include<iostream> using namespace std; int main() { double a,b,c,d,e,f=0; cin>>a>>b>>c; d=a*c*0.01; e=a-d; a=e; if(a<=b) { cout<<f; return 0; } f++; while(a>b) { d=a*c*0.01; e=a-d; a=e; f++; } cout<<f; return 0;} |
| Brave Ballons | Niveditha | 1049. Brave Balloonists | 7 Oct 2016 20:50 | 2 |
import java.util.*; public class BallonNumber { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a[]=new int[10]; int count=0; int prod=1,i; for(i=0;i<10;i++) { a[i]=sc.nextInt(); } for(i=0;i<10;i++) { prod=prod*a[i]; } //System.out.println(prod); for(i=1;i<=prod;i++) { if (prod%i==0) { count+=1;
} } System.out.println(count); } } So this is my code but it says wrong answer but I get the same answer in ide.What is wrong with this code Please estimate max value of prod. Then compare it with int capacity. |
| test 11 ......sad.... | xinxin | 1336. Problem of Ben Betsalel | 7 Oct 2016 20:06 | 1 |
#include<iostream> #include<stdlib.h> #include<math.h> using namespace std; int main() {long double n; long long int m,i; cin>>m;
for(i=1;i<10000000000000000000;i++) { n=sqrt(i*i*i*m); if(n==floor(n+0.5)) { cout<<n<<endl<<i;break;} } fflush(stdin); getchar(); return 0;} |
| test 11 ......sad.... | xinxin | 1336. Problem of Ben Betsalel | 7 Oct 2016 20:04 | 1 |
#include<iostream> using namespace std; int main() { double n; long long int m,i; cin>>m;
for(i=1;i<10000000000000000000;i++) { n=sqrt(i*i*i*m); if(n==floor(n+0.5)) { cout<<n<<endl<<i; break; } } fflush(stdin); getchar(); return 0; } |
| What is the answer | Mehas | 1476. Lunar Code | 5 Oct 2016 16:36 | 3 |
...for test 40 40 40? My is 32460430015431999968619493682032835511850959272235390105491169601 Too small... Obviously, the answer is 2^1600 = (2^10)^160 ~ (10^3)^160 ~ 10^480 Right answer is 44462416477094044... Edited by author 05.10.2016 16:36 |
| WA#6 | Ilya (Vologda SPU) | 1576. Telephone Tariffs | 5 Oct 2016 13:57 | 4 |
WA#6 Ilya (Vologda SPU) 29 Oct 2009 00:40 I got WA#6, what is wrong? Re: WA#6 Oleg Strekalovsky [Retired] 30 Oct 2009 12:51 Send to me your solution - and I will try to find your mistake Edited by author 30.10.2009 22:44 Re: WA#6 Oleg Strekalovsky [Retired] 30 Oct 2009 22:47 I found your mistake. Test 0 1 0 20 0 300 1 25:00 right Answer: Basic: 25 Combined: 0 Unlimited: 300 Edited by author 30.10.2009 22:47 Re: WA#6 Husanboy Abdullayev 5 Oct 2016 13:57 I gave this test and took right answer: Basic: 25 Combined: 0 Unlimited: 300 but again WA#6. Why? Help me, please |
| WA at test#5 | Gopesh Tulsyan | 1073. Square Country | 5 Oct 2016 10:30 | 5 |
I am getting a WA at test #5 Here's my code : #include <iostream> using namespace std; int main(){ int n,i=1,count=0; cin>>n; while(n>0){ if(i*i<=n) i++; else{ n-=(i-1)*(i-1); i=1; count++; } } cout<<count<<endl; return 0 } Imagine you are given the following input: n=72. Given that 72 = 6*6 + 6*6 the answer should be 2, but your output is 3. This is happening because you are solving the problem using a greedy strategy. Here a greedy strategy does not work. If you want more information on why this technique does not work read chapter 15 and 16 of "Introduction to algorithms" by Cormen,Leiserson,Rivest and Stein. Thanks for the explanation... ^_^ 60000 Edited by author 05.10.2016 10:30 |
| accepted pure c code | Иван | 1068. Sum | 4 Oct 2016 22:29 | 2 |
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int n, tmp; long sum; scanf("%d", &n); if (n > 10000 || n < -10000) { printf("%d\n", 0); return 0; } if (n == 0) { printf("%d\n", 1); return 0; } if (n > 0) { /* positive */ if (n % 2 == 0) { /* even */ sum = n * (n / 2 - 1) + n + (n / 2); } else { /* not even */ sum = n * (n / 2) + n; } } else { /* negative */ if (n % 2 == 0) { /* even */ sum = n * (n / 2 + 1) - n - (n / 2) - 1; tmp = ~sum + 1; sum = tmp; } else { /* not even */ sum = n * (n / 2) - n - 1; tmp = ~sum + 1; sum = tmp; } } printf("%ld\n", sum); return 0; } /* n * (n / 2) + n not even */ /* n * ((n / 2) - 1) + n + (n / 2) even */ /* n * (n / 2) - n - 1 negative not even */ /* n * ((n / 2) + 1) - n - (n / 2) - 1 negative even */ #include<stdio.h> int main(){ int n,N,ans; scanf("%d",&N); if(N > 1){ n=N; }else{ n=-1*N+2; } ans=(n*(N+1))/2; printf("%d\n",ans); return 0; } Also accepted |
| What's wrong in this? (C#) | gholamali | 1068. Sum | 4 Oct 2016 22:25 | 3 |
using System; namespace gholamali { class Program { static void Main(string[] args) { try { int N = Convert.ToInt32(Console.ReadLine()); if (Math.Abs(N) <= 10000) { if (N > 1) Console.Write(((N + 1) / 2) * N); else Console.Write(((N + 1) / 2) * (2 - N)); } Console.ReadKey(); } catch { } } } } [TestCase("2", "3")] ((N + 1) / 2) * N when you divide on int (= 2) it produce int result (= 1) and total sum is wrong (= 2) (N + 1) / 2) * N First multiply and then divide by 2 Like (N + 1) *N) / 2 Otherwise it may not act like an integer. and for second case ((N + 1) * (2 - N)) / 2 Edited by author 04.10.2016 22:27 |
| Python got TLE16 on O(m*n) solution, C++ got AC even with Dijkstra. Please add PyPy! | Practician | 1325. Dirt | 4 Oct 2016 14:32 | 1 |
My old C++ solution got AC with optimized Dijkstra, O(v*log(v)), where v = m*n. The timing was 0,406 sec. Evidently, with Python (2.7, 3.4) I got TLE with the same solution. On my machine 500*500 case runs for 4.5 seconds. Then I realized O(m*n) solution and optimized input as much as possible (Python). It still gives TLE16, on my machine - runs for 2.3 seconds. Then I run code under PyPy (5.4.1, Python2.7 compatible) and on my machine it runs for 0.383 seconds only. I hope it would AC if PyPy is able to be selected as a programming language. Please add PyPy! Thanks |
| How to prove four cells is enough? | riparia | 1552. Brainfuck | 3 Oct 2016 22:17 | 1 |
|
| what is the test 7? | organmusic | 1801. The Revolution Cup | 3 Oct 2016 19:09 | 2 |
I have also got WA in the test 7. Is it necessary to sort the teams names before output? Edited by author 22.05.2015 03:17 Edited by author 22.05.2015 03:43 have you figured out what went wrong? I'm having the same problem with test #7 here... thanks |
| Java optimization tips | vlyubin | 1620. Clever House | 3 Oct 2016 13:50 | 2 |
Hey, do the guys that submit on Java use BigInteger and array of (2 x BigInteger)[2000][1000]? If yes, then how do they manage to pass the TL? Is it just a matter of Java optimization, or the solution is much harder than a simple DP? Thanks ! Edited by author 07.04.2012 06:11 It's more of a math problem than DP... If you find the right pattern the solution is pretty simple and no optimization trick is needed to pass time limit. good luck! |
| Problem 1200 Horns and Hoofs has been rejudged | Vladimir Yakovlev (USU) | 1200. Horns and Hoofs | 3 Oct 2016 05:30 | 3 |
New tests have been added. All solutions have been rejudged: 288 authors have lost AC. Hm, TL #2 after rejudge... apparently old tests are changed too. Edit: i see, thanks~ Edited by author 03.10.2016 12:11 Old tests haven't been changed. Your solution's verdict on test #2 has changed from "slightly under TL" to "slightly above TL". There were a few such cases in total. |
| WA#33 | Anton juver++ Postnikov | 1280. Topological Sorting | 2 Oct 2016 22:16 | 9 |
WA#33 Anton juver++ Postnikov 25 Jun 2006 01:42 Who can give me some tricky tests for this problem, please! May be you need a more tricky algo? It's unable to have WA with this problem (quite simple algo) Please help, i have the same problem but i don't know where is my error here is code #include <iostream> using namespace std; int power[1005]; int deg[1005]; int mas[1005][1005]; int n,m; int answers[1006]; void input() { cin>>n>>m; int a,b; for(int i=0;i<m;i++) { cin>>a>>b; mas[a][power[a]++] = b; deg[b]++; } for(int i=0;i<n;i++) cin>>answers[i]; } void solve() { for(int i=0;i<n;i++) { if (deg[answers[i]]>0) { cout<<"NO"; return; } for(int j=0;j<power[answers[i]];j++) deg[mas[answers[i]][j]] --; } cout<<"YES"; } int main() { input(); solve(); return 0; } Re: WA#33 Nechaev Ilya (Rybinsk SAAT) 10 Nov 2006 04:00 I don't know what are you doing, but you need just check M conditions for given sequence. I don't know what can be wrong. Edited by author 10.11.2006 04:29 Re: WA#33 Nechaev Ilya (Rybinsk SAAT) 10 Nov 2006 04:20 Haha. I just changed int mas[1005][1005]; to int mas[1005][10005]; and get AC. I think that each limitation can occur in the input more than once i.e. some limitations can be equal :-p Advice: this solution use too much memory. Really you need less than 1 Mb. Edited by author 10.11.2006 14:02 Thank you for advise. Now i just changed adjanced list stored in array to vector<vector<int> > . And my programm used only 860 Kb. Haha. I just changed int mas[1005][1005]; to int mas[1005][10005]; and get AC. I think that each limitation can occur in the input more than once i.e. some limitations can be equal :-p Advice: this solution use too much memory. Really you need less than 1 Mb. Edited by author 10.11.2006 14:02 I'm very appreciate you. I used vector<vector<int> > and eventually got AC:-) Thank you for the advice about limitations! |
| WA6 | coder | 1709. Penguin-Avia | 2 Oct 2016 11:07 | 9 |
WA6 coder 4 Apr 2009 16:30 Please, give me some hint! Standard Prim's(Greedy) algo works if we assign -d to edges in graph. Re: WA6 Lucian Ilea 30 Jun 2009 14:47 nothing special, just obtain a spanning tree (forest)... I think you made a confusion between verteces and parents, or something like that... try this example: 7 2 10 0000101 0000101 0001010 0010010 1100001 0011000 1100100 One of the correct answers is 16 00a000d 0000000 a0000d0 0000000 000000d 00d0000 d000d00 Re: WA6 FatalityNT 23 Oct 2013 13:55 Thanks you. This test helped me to find the reason of WA6. Re: WA6 Jane Soboleva (SumNU) 22 Feb 2016 06:26 Had a very silly WA6, and none of tests from this or neighbouring topics helped, so here's the one that i finally thought of and which helped: 5 1 1 01000 10001 00010 00101 01010 (1-2, 2-5, 5-4, 4-3, result is all zeros.) I've been sleepy and lazy and did a bad job with a tree building algo, which i made like this: --- (mark vertices 1..N as unconnected) for i:=1 to N do for j:=1 to N do if (i, j) is an existing edge and either i or j is yet unconnected to anything, then add (i, j) to a tree and mark both i and j as connected. --- So then it adds 1-2, then 2-5, then 3-4, and then it appears that both 4 and 5 are already connected to something, and 4-5 isn't included to a tree, which is a mistake. Re: WA6 Kairom `Ekexity 💻 31 Aug 2016 12:56 My programm have wa6? and on your test give: 16 0000000 000000d 000000a 00000d0 000000d 000d000 0da0d00 Is it correct? I've WA6 too. But on pervious test I've got AC. I use connected components of graph and Kruskal algo for builting spanning tree. Re: WA6 Samsonov Alex [USU] 6 Jul 2009 20:38 Try to estimate the maximal possible answer to this problem. |
| Seems like impossible to pass with python | Infoshoc | 1577. E-mail | 30 Sep 2016 22:15 | 1 |
Python: 7028591 The same C++: 7028621 Please increase memory limit or disable python. Thanks |
| Output limit exceeded | sikder_social | 1409. Two Gangsters | 30 Sep 2016 19:40 | 3 |
What is wrong in my code? Thanks [code deleted] Edited by moderator 19.11.2019 23:57 Well, there's only two numbers in the input. For some reason you're using while, and for some reason it leads to infinite cycle apparently. Try to replace your while with if. Also, you assume there's exactly 10 cans total. This is not true. The task says "no more than 10". Edited by author 30.09.2016 18:25 while becomes endless because of mistake: Current state: while(scanf("%d %d",&a,&b)!=EOF && a<11 || b<11){ Should be: while(scanf("%d %d",&a,&b)!=EOF && (a<11 || b<11)){ |