Common Board#include <iostream> using namespace std; int main() { int a, b; cout << "Enter the first number: "; cin >> a; cout << "Enter the second number: "; cin >> b; cout <<"the result: "<< a + b << endl; return 0; } Комментарии к вводу уберите delete please/ Edited by author 13.11.2014 21:07 I tried the following: #include<stdio.h> #include<math.h> #include<string.h> int main (){
unsigned long long int *inputNumber; int i = -1; int memoryUsed = 0; //256 KB limit
unsigned long long int input= 0;
while( input != EOF ){ scanf("%llu", &input); if( input == EOF) break; if ( memoryUsed > 262144 ){ printf("memory Exceed"); break; } inputNumber[++i] = input; memoryUsed = memoryUsed + 8; };
for( ; i >= 0 ; i-- ){ printf("%.4f\n", sqrt(inputNumber[i])); }
return 0; } but it gives same error problem solved Edited by author 14.10.2015 11:08 why wrong answer? #include <iostream> using namespace std; int main() { int banki=10, banki_s, bankis_ss; cout << "Harry shot cans: "; cin >> banki_s; cout << "Larry shot cans: "; cin >> bankis_ss; cout << "Harry shot: " << (banki - banki_s) << endl; cout << "Larry shot: " << (banki - bankis_ss) << endl;
return 0; } int main() { code: int banki, banki_s, bankis_ss; cout << "Harry shot cans: "; cin >> banki_s; cout << "Larry shot cans: "; cin >> bankis_ss; banki = (banki_s + bankis_ss) - 1; cout << "Harry shot: " << (banki - banki_s) << endl; cout << "Larry shot: " << (banki - bankis_ss) << endl; system("PAUSE"); return 0; } Sorry for russian comments, I don't speak English well. Why WA? (system("pause"); is only for checking, of course) #include <iostream> using namespace std; int main() { unsigned long N, P, A; cin >> N; for (A = 1; A <= N; A++) // чтобы P было максимальным, начинаем с меньшего А { // прокручиваем P с N/A вниз, т.к. вроде бы это минимальное число с которого следует начинать for (P = N / A; P*A + P*(P - 1) / 2 > N; P--); if (P*A + P*(P - 1) / 2 == N) // если нашли - останавливаемся break; } cout << A << ' ' << P; system("pause"); return 0; } Edited by author 24.02.2015 13:16 OK, if someone came here for spoiler, T0 != 0 in test 4 I don't know what problem..... Can help me ...? -------------------------------------------------------------------------- Code: #include <stdio.h> #include <math.h> main(){ unsigned long long int inn[99999],count=0; while(scanf("%llud",&inn[count])!=EOF){ count++; } printf("count:%d\n",count); for(;count>0;){ count--; printf("%0.4f\n",sqrt(inn[count])); } return 0; } ------------------------------------------------------------------------- Thanks for help. Edited by author 17.05.2014 23:37 Here is the solution in Java: import java.io.*; import java.util.*; import java.text.DecimalFormat; public class Task { public static void main(String[] args) { DecimalFormat df=new DecimalFormat("0.0000"); int i,max; double[] massiv=new double[130197];//130196 - runtime error at test #9 Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); max=1; while(in.hasNextDouble()){ massiv[max]=Math.sqrt(in.nextDouble()); max++; } max--; for (i=max;i>=1;i--) System.out.println(df.format(massiv[i])); out.flush(); } } But I don't understand the next thing: if I change the size of array from 130197 to 130196 I'll be given "runtime error" at test #9. Why it should be 130197? How does 256 Kbytes input stream correlate with 130196 double type elements ? Edited by author 20.06.2014 21:46 Edited by author 20.06.2014 21:48 Edited by author 21.10.2014 23:22 Decrease the size of you inn Array. set it to 99 then try. who can prove it if the amount of baffles that should be opened is equal to N - 2, it will be not enough, because graph will be not connected, and that's why not all cockcroaches will reach the floodgate. But you can build the spanning tree of this graph. It has exactly N - 1 edges, and graph will be connected and now all cockroaches will reach the floodgate. please can anyone tell me what is the test of 4????? #include <iostream> #include <conio.h> using namespace std; struct abonent { char login[30]; char password[30]; short status; }; int main() { short n, k = 0, j, compare, index; char *part_str; char str[80]; cin >> n; abonent *peop = new abonent[n]; gets(str); for (int i = 0; i < n; i++) { gets(str); part_str = strtok(str, " "); if (!(strcmp(part_str, "register"))) { part_str = strtok(NULL, " "); strcpy(peop[k].login, part_str); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(peop[k].login, peop[j].login))) { compare = 0; break; } } if (compare) { part_str = strtok(NULL, " "); strcpy(peop[k].password, part_str); peop[k].status = 0; k++; cout << "success: new user added\n"; } else { cout << "fail: user already exists\n"; } }
if (!(strcmp(part_str, "login"))) { part_str = strtok(NULL, " "); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(part_str, peop[j].login))) { compare = 0; index = j; break; } } if (!compare) { part_str = strtok(NULL, " "); if (!(strcmp(part_str, peop[index].password))) { if (peop[index].status) { cout << "fail: already logged in\n"; } else { peop[index].status = 1; cout << "success: user logged in\n"; } } else { cout << "fail: incorrect password\n"; } } else { cout << "fail: no such user\n"; } } if (!(strcmp(part_str, "logout"))) { part_str = strtok(NULL, " "); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(part_str, peop[j].login))) { compare = 0; index = j; break; } } if (!compare) { if (peop[index].status) { peop[index].status = 0; cout << "success: user logged out\n"; } else { cout << "fail: already logged out\n"; } } else { cout << "fail: no such user\n"; } } } delete[] peop; return 0; } Edited by author 24.02.2015 02:52 Use QWORD instead of INT64! Thank you.I've got ac now. Thank you. Changed from signed int64 to unsigned int64 for c++. https://uzdisk.uz/public.php?service=files&token=dacc643443b8fa3475306cd6b57a9277a6d354a5&file=/acm.timus.ru/1496.%20%D0%A1%D0%BF%D0%B0%D0%BC%D0%B5%D1%80.cpp #include <iostream> #include <string> #include <algorithm> using namespace std; int n; string array[10001]; struct TSpamer { string name; short index; }Spamer[10001]; void my_sort(int j) { int ind = 0; int Min_element = Spamer[ind].index; for(int i=0; i<j; i++) { int l = 0; while(l < j) { if(Spamer[l].index <= Min_element) { Min_element = Spamer[l].index; ind = l; } l++; } cout << Spamer[ind].name << endl; Min_element = 101; Spamer[ind].index = 102; } return; } int main(void) { int counter = 1; cin >> n; for(int i=0; i<n; i++) cin >> array[i]; sort(array, array+n); int k = 0, j = 0; while(k < n-1) { for(int i=k+1; i<n; i++) if(array[k] == array[i]) counter++; if(counter > 1) { Spamer[j].index = counter; Spamer[j].name = array[k]; j++; } k += counter; counter = 1; } my_sort(j); return 0; } Edited by author 16.10.2013 20:53 check my sol :P #include <iostream> #include <set> #include <string> using namespace std; int main () { string a[103]; set<string> gh; int n; cin >> n; for(int i = 0; i < n; i++)cin >> a[i]; for(int i = 0; i < n - 1; i++){ for(int j = i + 1; j < n; j++) if(a[i] == a[j]){gh.insert(a[i]);} } while (!gh.empty()){ cout << *gh.begin() << "\n"; gh.erase(gh.begin());} } Edited by author 20.02.2015 15:18 Please give me test...My code : import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Park1796_ { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int a[] = new int[6]; int max = 999999999, k = 0; for (int i = 0; i < a.length; i++) { a[i] = in.nextInt(); if (a[i] != 0 && a[i] < max) { max = a[i]; k = i; } } int b = in.nextInt(); int sum = 0; sum += a[0] = 10 * a[0]; sum += a[1] = 50 * a[1]; sum += a[2] = 100 * a[2]; sum += a[3] = 500 * a[3]; sum += a[4] = 1000 * a[4]; sum += a[5] = 5000 * a[5]; switch (k){ case 0: k = 10; break; case 1: k = 50; break; case 2: k = 100; break; case 3: k = 500; break; case 4: k = 1000; break; case 5: k = 5000; break; } int l = 0, d = sum - k; int count = 0, f = 0; f = d / b + 1; while (f * b <= sum && f * b >= d){ out.print(f + " "); count++; f++; } System.out.println(count); out.flush(); } } Edited by author 19.02.2015 03:01 import java.util.Scanner; public class JavaThieves877 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int c1 = Integer.parseInt(scanner.next()); int c2 = Integer.parseInt(scanner.next()); if (c1 % 2 == 0 || c2 % 2 != 0) { System.out.print("Yes"); } else if (c1 % 2 != 0 || c2 % 2 == 0) { System.out.print("No"); } } } If you use formula in C++, you don't need the long arithmetics. Use long double and you'll get AC. i used long double, 2 4 6 29 -1000 but my answer is -6.00693e+208, is it correct or not? you should turn off siencetific notation My approach goes like this: lets choose a big random prime P > 10^16, and calculate F_(i+1)%P. bits/stdc++.h -> TLE on Test #4 cstdio -> TLE on Test #4 stdio.h -> AC Compiled with: G++ 4.9 C++11 Can anyone give an explanation? var podschet,a,b,i:integer; begin a:=1; for i:=1 to 10 do begin readln(b); a:=a*b; end; for i:=1 to a do begin if a mod i=0 then podschet:=podschet+1; end; if podschet>9 then podschet:=podschet div 10; writeln(podschet); end. Edited by author 11.12.2014 15:46 Mistake is in this line: if podschet>9 then podschet:=podschet div 10; To take last digit you should be using mod instead of div. Edited by author 15.02.2015 23:31 Edited by author 15.02.2015 23:31 Here's my code: import math a = input() a = a.replace('\n', ' ') a = a.split() a.reverse() for i in a: print(math.sqrt(float(i))) Edited by author 10.05.2014 16:59 What we are inputting is a stream of inputs, that may contain '\n'. On the other hand, input() cannot contain newline character. #include<iostream> using namespace std; int main() { long int N,i,sum=0; cin >> N; if (N > 10000 || N < -10000) { cout<<sum; return 0; } if(N>0) for(i= N; i>= 1; i-- ) sum=sum+i; if(N<0) for(i= N; i<=1; i++) sum=sum+i; cout<<sum; } What kind of projection? Orthographic or perspective? Edited by author 15.02.2015 14:43 |
|