| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
| What is test 2 and what is wrong with my code? C programming language | creaky | 1068. Сумма | 16 окт 2012 16:06 | 3 |
#include<stdio.h> main() { int a, sum=0; scanf("%d",&a); if(a<0&&a>=-10000) { int i; for(i=a;i<=1;i++) { sum=sum +i;
} printf("%d",sum); } else if( a>=0&&a<=10000) { int i; for(i=1;i<=a;i++) { sum=sum +i; } printf("%d",sum);
} }
when a = 0, the answer is 1, not 0 Edited by author 12.10.2012 23:50 I have executed the program and when I input 0 the result is also 0. But still they are not accepted |
| What's Wrong ! ACM Timus system wrote me WA № Test 1 . Can anybody help me? | Александр | 1083. Факториалы!!! | 16 окт 2012 15:33 | 1 |
#include <stdio.h> int fact(int n, int k){ int res = 1; if (n == 0) return res; while (n > k) { res *= n; n -= k; } if (n % k) res *= (n % k); else res *= k; return res; } int main () { char sym; int n = 0; int symCount = 0; scanf("%d ", &n); while (scanf("%1[!]", &sym) == 1) { symCount++; } printf("%d\n", fact(n, symCount)); return 0; } |
| My formula | PrankMaN | 1502. Точки домино | 16 окт 2012 15:22 | 3 |
Answer for n is n*(n+1)/2*(n+2) For example if n=2 then answer is 2*3/2*4=12 The formula is correct and is easily proven by solving the sums: sum(i=0 -> N) sum(j=0 -> N) (i + j) Edited by author 03.02.2012 17:25 Actually the inner sum needs to start at i, not at zero. Starting at 0 counts non-double dominoes twice. |
| Why 0.015? | partisan | 1502. Точки домино | 16 окт 2012 15:15 | 2 |
My program only read integer and write integer (ready formula). Why it works 0.015 sec? Edited by author 11.06.2009 00:15 Because this is the minimum measurement time possible on the current version of the judge. |
| Some hint for you (Very exciting problem, although it's easy at the first time). | Phan Hoài Nam (Harvey Nash) | 1142. Отношения | 16 окт 2012 11:29 | 2 |
Let a be the number of objects. Let b be the number of objects in a group. Let A[a] is the number of permutations of a objects ( A[2] = 2, A[3] = 2*3, A[4] = 2*3*4...) So: f[a][b] is the number of groups with b objects. You have the formula: f[a][b] = f[a-1][b] * b + f[a-1][b-1]; And the result = f[n][1] * A[1] + f[n][2] * A[2] + ... + f[n][3] * A[3] A group is formed by equal objects in a relation. For example: a = b < c = d (2 groups ab and cd) a = b < c < d (3 groups ab, c and d) ... I think when N is increased to 1000, everyone will solve it by DP or maths, not cheat :-) thank you for your idea. I had learnt a lot from yours. |
| trie+dp | stupidjohn | 1002. Телефонные номера | 16 окт 2012 10:05 | 2 |
trie+dp stupidjohn 19 ноя 2010 18:18 solve it with c++ algo are: dp[i,j]=dp[i,k]&&dp[k+1,j] main code are: for(length=0;length<n;length++) { for(i=0;i+length<n;i++) { if(find(i,i+length,maintree)) { dp[i][i+length][0]=9999; dp[i][i+length][1]=1; save[i][i+length]=choose; } else { bestadd=100;bestj=-1; for(j=i+1;j<i+length;j++) if(dp[i][j][0]!=-1&&dp[j+1][i+length][0]!=-1) { if(dp[i][j][1]+dp[j+1][i+length][1]<=bestadd) { bestadd=dp[i][j][1]+dp[j+1][i+length][1]; bestj=j; } } dp[i][i+length][0]=bestj; dp[i][i+length][1]=bestadd; } } } hope it will do you a favor |
| Who know Test 10 ??? Help me !!!! | dangtrinh93 | 1014. Произведение цифр | 16 окт 2012 09:12 | 1 |
i try to find but i don't know where i'm wrong ?? Who know test 10, please tell me !!! Tks very much |
| How can my program get AC even it returns wrong answer for the first test? | JAVATAR | 1723. Книга Сандро | 16 окт 2012 07:38 | 3 |
Hello, How can my program get AC even it returns wrong answer for the first test? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter;
public class SandrosBook {
public static void main(String args[]) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out=new PrintWriter(System.out);
int[] a=new int[26];
String s=br.readLine(); int i=1; int start=0,end=0; start=s.charAt(0)-97; int max=0;
while(i<s.length()){ char c=s.charAt(i); a[(int)c-97]++; i++; }
int k=0; for(int ii=0;ii<26;ii++){ if(a[ii]>max) { max=a[ii]; k=ii; } }
k=k+97;
System.out.println((char)k); out.flush(); }
} try test: b right answer "b", but you output "a" Edited by author 09.03.2012 14:09 |
| I made everything, but still Wa 1. | -XraY- | 1307. Архиватор | 16 окт 2012 01:51 | 3 |
There is my code. My stress works fine. The size of output program is something near 4/5 * length bytes. Using gets, all endl are written as '@'. There is an assert, that i haven't forgotten some symbols. Please, help! http://pastebin.com/WnQvat6gI suggest I got CE because of too long strings.) Stupid compiler:) I got AC) I have some question: why symbols '[', ']' and '~' are included in the texts? It's not clear from the statement, but I checked: output of your program (program, that prints input and has little size) may have size more than 64kb (all programs have some restrictions to the size in bytes). |
| Could someone please kindly explain the example solution provided. | Anupam Ghosh, Wipro Technologies | 1638. Книжный червь | 15 окт 2012 22:37 | 2 |
Apologies, since I started this thread. Understood the problem got AC. when I placed two books on shelf side by side I understood the problem. Thanks to all memebers who posted in other threads. Regards Anupam Edited by author 11.03.2012 02:41 The problem relies on the unstated assumption of how people "normally" put books on shelves, and assumes that the pages in the book are arranged like books in Western languages. |
| Easytask!!!!!! | Anastas | 1206. Сумма цифр суммы чисел | 15 окт 2012 20:41 | 8 |
Just use long arithmetics and calculate 36*pow(55,k-1); How did u get the formula What are the libraries and functions u use for long arithmetic in c++. There are no such libraries! You must write long arithmetics by yourself ;) Thank finaly something extra ordinary good. Thanks allot. I was searching for this for so long time. Thanks, thanks, thanks... This program explain how get 36 and 55. #include <iostream> using namespace std; __int64 s( __int64 x ){ __int64 ans = 0; while( x ){ ans += x % 10; x /= 10; } return ans; } int main(){ __int64 kol = 0; for( __int64 i = 0; i <= 9; ++i ){ for( __int64 j = 0; j <= 9; ++j ){ if( s(i+j) == s(i)+s(j) && i+j<=9 ){ cout << " " << i << " " << j << " s=" << s(i+j) << endl; ++kol; } } cout << "-------------------------" << endl; } cout << "kol = " << kol << endl; kol = 0; for( __int64 i = 1; i <= 9; ++i ){// последний разряд без нулей т.к. число must be без ведущих нулей for( __int64 j = 1; j <= 9; ++j ){ if( s(i+j) == s(i)+s(j) && i+j<=9 ){ cout << " " << i << " " << j << " s=" << s(i+j) << endl; ++kol; } } cout << "-------------------------" << endl; } cout << "kol = " << kol << endl; return 0; } Edited by author 23.11.2011 03:11 Edited by author 23.11.2011 03:12 Edited by author 23.11.2011 03:12 |
| WA #3 | Max Pilgrim | 1642. Одномерный лабиринт | 15 окт 2012 19:03 | 5 |
WA #3 Max Pilgrim 22 янв 2009 18:01 Edited by author 06.04.2009 19:06 try this 2 999 1000 -1000 the correct answer is 999 2999 Edited by author 21.12.2011 21:02 Edited by author 21.12.2011 21:02 Re: WA #3 Anupam Ghosh, Wipro Technologies 15 окт 2012 19:03 Hi Panther.uz, try this 2 999 1000 -1000 the correct answer is 999 2999 This is correct answer as the exit is at 999 so in positive direction if a person walks 999 he escapes. This explains first answer. If a person walks in reverse he encounters obstruction at 1000. Thus he reverses to origin and proceeds to exit. Total 1000+1000+999=2999. Hope this helps. Regards Anupam |
| non-decreasing | Ciprian Olariu | 1903. Неопознанные корабли | 15 окт 2012 18:48 | 2 |
Does non-decreasing mean that is an increasing sequence of numbers? "non-decreasing" includes the possibility that some numbers are equal to the prior number. |
| Probable weak tests | Marginean Ciprian | 1871. Сейсмические волны | 15 окт 2012 13:34 | 2 |
Consider the following test: 7 Wayne 2 Bruce Dick Bruce 1 Brown Dick 1 Grayson Brown 1 Gordon Grayson 1 Gordon Gordon 1 Stephanie Stephanie 1 Wayne Master Wayne is going to disguise as Batman and stop the Joker! I must prepare the Batmobile for his quest! My solution fails to print Stephanie as a person who received the tweet about the earthquake. My solution uses a shortest path algorithm and that is why it takes into consideration only the shortest tweet reaching Gordon(the tweet sent by Grayson). So Gordon will try to send the tweet that he received(on the path Wayne Dick Grayson) preappended with "RT @Grayson: "(which is 13 characters long), totalling 141 characters. So the algorithm concludes that Stephanie will receive no tweet. But if we take the path Wayne, Bruce, Brown to Gordon, Gordon will receive a longer tweet than on the other path, but Stephanie will receive a tweet totalling 140 characters so she will actually be notified by a tweet too, although my algo fails to notice this. I believe that there are great chances that other shortest path algos implemented by other users behave the same, so please try to consider improving the tests with a test similar with mine, Regards, Ciprian Edited by author 15.10.2012 00:16 Your test was added. Thank you. |
| WA 4 | IgorKoval(from Pskov) | 1904. Уроки прошлого | 15 окт 2012 02:21 | 1 |
WA 4 IgorKoval(from Pskov) 15 окт 2012 02:21 if you get WA 4 and you solve the problem from the end, than (maybe) you must take into account that sensor return only possitive number or null ans intermediate value can be >= 0. Edited by author 15.10.2012 02:29 |
| Crash Where is my mistake? | behzodbek | 1269. Антимат | 15 окт 2012 00:37 | 1 |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int n = sc.nextInt(); String S[] = new String[n]; for (int i = 0; i < n; i++) { S[i] = sc.next(); } int m = sc.nextInt(); String[] S2 = new String[m]; for (int i = 0; i < m; i++) { S2[i] = bf.readLine(); } int count = 0, tempcont = 0; boolean isFineded = false; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { StringTokenizer st = new StringTokenizer(S2[i]); count -= tempcont; tempcont = 0; while (st.hasMoreTokens()) { tempcont++; String temp = st.nextToken(); if (isExits(temp, S[j])) { count++; isFineded = true; System.out.println(i + 1 + " " + count); } else { count++; } } } tempcont = 0; } if (isFineded == false) { System.out.println("Passed"); } } static boolean isExits(String src, String str) { boolean bol=false; if (str.length() > src.length()) { return false; } else if (str.equals(src)) { return true; } else { for (int i = 0; i <= src.length() - str.length(); i++) { if (str.equals(src.substring(i, i + str.length()))) { bol=true; } } return bol; } } } |
| what's wrong? on my pc it works right... (Pascal) | jss94 | 1642. Одномерный лабиринт | 14 окт 2012 19:03 | 1 |
var n,i,k:byte; x,d,y:integer; m:array[0..100] of integer; begin read(n,x); for i:=1 to n do read(m[i]); k:=0; y:=n; if x<0 then begin for i:=1 to y do begin if (m[i]>x) and (m[i]<0) then begin writeln('Impossible'); k:=k+1;end else begin if m[i]<0 then begin y:=abs(x); end; if m[i]>0 then d:=m[i]; end; if m[i]<d then d:=m[i];end; writeln(d+d+abs(x)); writeln(y); end; if x>0 then begin for i:=1 to n do begin if (m[i]<x) and (m[i]>0) then begin writeln('Impossible'); k:=k+1;end else begin if (m[i]>x) and (m[i]>0) then begin d:=x; writeln(d);end; if m[i]<0 then d:=m[i];end; if (m[i]<0) and (m[i]>d) then d:=m[i]; end; writeln(abs(d)+abs(d)+x); end; end. |
| WHY ACCEPTED??? | OlgaX | 1180. Игра с камушками | 14 окт 2012 17:43 | 5 |
Sorry for Russian... моё решение задачи... перевожу число в двоичную чистему исчисления.. считаю количество единичек.. если это количество четное, то выиграл второй, если нечетное, то первый... Почему такое решение проходит все тесты??? Оно же неверное.. например при N=5 моя прога выдаст, что выиграл второй, хотя на самом деле выигрывает первый, взяв 2 камня... Really... Probably it's another one problem with easy tests. PS: На acm.timus.ru много таких задач, тесты требуют доработки :( Иногда проходят ну очень странные решения :) все правильно выйграет второй, по 1 камню тоже можно брать |
| WA in Case 4 no clue | Sanzee | 1018. Двоичная яблоня | 14 окт 2012 16:22 | 2 |
found my mistake Edited by author 26.06.2012 01:56 i got the same problem! can u plz tell what was your mistake :) |
| Could anybody show me the formula? | Endorphin | 1327. Предохранители | 14 окт 2012 16:22 | 5 |
I've got AC by stupid brute force, like if (i % 2) k++;. But i think that there is a easier way to solve this task. Topic. но это не тупой брутфорс, просто в четные дни он не ломает предохранители. 100-ый день четный, поэтому ответ 50, а не 51 Seriously, guys, put away correct formulas, please. If ((last day) mod 2 = 0) than formula = ((b - a)+1)/2 else formula = ((b - a) + 2) / 2 I got AC Because if we our seconf day mod = 0, it means, that we mustn't count last day, only add 1. If our second day mod 2 = 1, it means, that we must count second day, add 2. That's easy Edited by author 14.10.2012 16:23 Edited by author 14.10.2012 16:24 |