Общий форум var a:array[1..10000] of Longint; b:array[1..10000] of string; min,c,n,i,j,k:Longint; s:string; begin read(n); for i:=2 to n-1 do begin if n mod i=0 then j:=i; if (j<>0) and (j<10) then begin k:=k+1; str(j,b[k]); str(trunc(n div j),s); b[k]:=b[k]+s end; end; for i:=1 to k do val(b[i],a[i],c); min:=a[1]; for i:=1 to k do if min>a[i] then min:=a[i]; if min<>0 then write(min); if j=0 then write('-1'); end. #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int A=140000, i; double a[14000]; for(i=0; cin >> a[i]; i++) { a[i] = sqrt(a[i]); } i--; for( ; i>=0; --i) { cout << fixed; cout << setprecision(4) << a[i] << endl; } return 0; } #include <iostream> #include <cmath> #include <iomanip> #include <vector> using namespace std; __int64 li; vector<double> vp; double a[14000]; int i=0; void solve() { for( ; cin >> li; i++) { vp.push_back(sqrt(static_cast<double>(li))); } for(int j=vp.size()-1; j>=0; j--) { cout << fixed; cout << setprecision(4) << vp[j] << endl; } } int main() { solve(); return 0; } http://delphiforfun.org/Programs/knights_tour.htm A technique known as Warnsdorf's heuristic allows us to make much better choices for next move than random selection. The heuristic, discovered by H. C. von Warnsdorf in 1823 tells us to select as our next move the one which has the fewest choices for moving on from there. This heuristic works so well that , although I have implemented backtracking to remove bad choices, I have yet to see a move retracted while making a tour Warnsdorf's idea works in linear time! Amazing power of human mind.. :) WA 10, any more tests? finally got AC.. be careful with overflow WA ON 43!!! Ouch. Input limits? Make sure variable types can hold the required range of values? solved. It's 0 0 cases thank u for attention Edited by author 19.11.2012 22:12 Edited by author 19.11.2012 22:13 import java.util.*; public class HistoryExam { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); List<Integer> professorsList = new ArrayList<Integer>(); for (int i = 0; i < a; i++) { professorsList.add(sc.nextInt()); } int b = sc.nextInt();
int counter = 0;
for (int i = 0; i < b; i++) { int c = sc.nextInt(); if (Collections.binarySearch(professorsList, c)>=0) { counter++;
} } sc.close(); System.out.println(counter); } } Merge Unstable? Why i got "WA" in #test4? I'm going crazy! Edited by author 15.12.2012 09:15 chufff Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 Hint: Keep only their frequencies and see what you can do from there. Edited by author 28.06.2012 20:47 Кто может объяснить второй тест, почему нет решений? потому что в условии сказано: "объявление произнесли на каждом языке не более одного раза" а во втором случае дважды проскакивает english. Значит Игорь ошибся. I have found two other points of square by this formula xc = (x1 + x3) / 2.0; yc = (y1 + y3) / 2.0; dx = (x3 - x1) / 2.0; dy = (y3 - y1) / 2.0; x2 = xc - dy; y2 = yc + dx; x4 = xc + dy; y4 = yc - dx; But i could not understood why this works. Then I use vector product to determine position of point etc. Can someone explain me ? This is my code on C++. The wrong is in the test №6. Why? Help me, please. #include <iostream> using namespace std; int main() { int k, n, sum=0, a, i, mas[100]; cin >> k >> n; if (k>=1 && n<=100) { for (i=0; i <= n-1; i++) { cin >> mas[i]; if (mas[i] <= 100 && mas[i] >= 0) sum = sum + mas[i]; else continue; } a = n * k; if (sum > a) cout << sum - a << endl; if (sum <= a) cout << 0 << endl; } return 0; } why is it wrong this code if (x==0 || y==0) printf ("%lld %lld",x,y); else if (x % 2 != y % 2 ) printf ("%lld %lld",y,x); else printf ("%lld %lld",x,y); test #9 crash(access violation) double..[65536] ???? who can help me?? oh....it's my code int main(void) { double number,root,temp,answer[65536]; int i=0; while(EOF!=scanf("%lf",&number)) { if(number==0) root=0; else { root=1; temp=(root+number/root)/2; while(root!=temp) { root=temp; temp=(root+number/root)/2; } } answer[i++]=root; } for(i-=1;i>=0;i--) printf("%.4lf\n",answer[i]); return 0; } double number,root,temp,answer[65536]; Size of test is not more than 256 KB. If each number consists from only one digit and there are blank spaces between numbers so no more than 131072 numbers could be in one test, not 65536. I suggest to replace "K is the maximum result" with "K is the maximum difference of gold". May I to bend the cut cylinder? Errors of calculations - reason of mistakes :) 9 !! - ввод 945 - вывод пишет wrong answer var n,i:integer; res:longint; k:string; begin read(n,k); i:=0; res:=1; if n mod length(k)=0 then repeat res:=res*(n-i); inc(i,length(k)); until n-i=length(k) else repeat res:=res*(n-i); inc(i,length(k)); until n-i=1; writeln(res); end. как решил mne toje takoy: --------------------- var x,s:string; s1,j,i,c,l:longint; begin read(x); repeat i:=i+1; s:=s+x[i]; until x[i]=' '; l:=length(x)-i; val(s,s1,c); j:=s1; repeat j:=j-l; s1:=s1*j; until j<=1; write(s1); end. On submission 4620967 a have verdict MemoryLimit, but used memory is 8954KB. |
|