|
|
Common Boardtest case : RGBY RGBY answer : equal According to the segement discussion, re-paintings include [a,b] and we have to output (a,b), So how the output for TEST1 is (47,634) ? According to me the output should be (47,635) as 634 will be painted due to 3rd repainting.
Check this test case: 2 A TL 6 A TL 7 Correct answer is 1 1 Check this simple test : 10 Agabek WA 7 Adhambek TL 7 Agabek TL 3 Agabek AC Sirius CE Sirius AC Adhambek WA 5 Sirius WA 5 Sirius ML 7 Adhambek AC answer : 3 3 My accepted program gives me : test 1 : 5 2 6854726 5664 2 2 34 1 5646532 40 1100000 answer : 2 0 2 5 8 #include <iostream> using namespace std; int main() { int N, M; int S[15001]; int S1[1000001]; cin >> N; for (int i1 = 1; i1 <= N; i1++) cin >> S[i1]; int f = 0; cin >> M; for (int i = 1; i <= M; i++) cin >> S1[i]; for (int i1 = 1; i1 <= N; i1++) for (int i = 1; i <= M; i++) if (S[i1] == S1[i]) f++; cout << f; }
S[15001] <--> S[0..15000] S1[1000001] <--> S1[0..1000000] the product is : n*(n-k)*(n-2*k)... till---> k if divisible by k, i.e. the last non zero value of n OR n(mod)k which is again the last non zero value of n. You don't have to multiply it with k or n mod k again. May be your program is O(n^2) you can use an array. f[i] means there are f[i] '1' after s[i]. (I can't speak English well.) No additional array is required. Only several auxiliary variables. I know how to identify end of console in Pascal, C/C++, but in Java it's not working. Anybody knows? What is the bug in my code? import java.io.*; public class ACM1601 { public static void main(String[] args) throws IOException{
boolean isNewSntc = true; String line=""; int ch; while ((ch = System.in.read()) != -1) { if (isNewSntc){ line += Character.toString((char)ch); isNewSntc = false; } else { line += Character.toString(lowerCase((char)ch)); } if (ch == 46 || ch == 63 || ch == 33) isNewSntc = true; }
System.out.println(line); }
public static char lowerCase(char in) { if ((int)in > 64 && (int)in < 91) return (char) ((int)in + 32); return in; } } Edited by author 31.12.2013 22:26 Edited by author 31.12.2013 22:26 Does this work? import java.io.*; class CopyFirst { public static void main(String[] args) throws IOException { int ch; while ((ch = System.in.read()) != -1) System.out.print((char)ch); } } please send me the test data at least for test 1, i have trouble understanding what is wrong with the code just going blindly, after running all the tests i could find and succeeding still not able to pass first one. tx //1639. Chocolate 2 #include<stdio.h> int main() { int n; printf((scanf("%d",&n)*n*scanf("%d",&n)*n)%2==0?"[:=[first]\n":"[second]=:]\n");
} it works fine in my compiler..but don't know why it shows wrong answer here while submission... Edited by author 31.12.2013 01:59 Deleted Edited by author 30.12.2013 20:05 I had some huge problems getting from WA9 to AC. Here is a test that might help you out: Input: 3 )))(( )))) ((((( Output: 14 3 3 1 2 I am using greedy strategy coeff = (unhappiness - possible reduced unhappiness)*length of line x is position to cut the line for min unhappiness ::::: add main list to priority queue with initial unhappiness while(cuts<K){ remove List with max coeff; cut in 2 parts for min unhappiness, calc coeff (for each list); add the 2 parts of list to queue; cuts++; } then poll all queue members(i.e. all cut lines) and add their unhappiness I'm getting all posted tests right.. I tried all variations I could, and I'm getting right answers, but I am getting WA#2, please help!!!! Edited by author 30.12.2013 21:16 My question is not particularly about this problem, but about printf output with precision 10^-6 or better. In this problem when I use float and output with printf("%.6f", ... ) I get WA8. When I use double and printf("%.6lf", ... ) I get WA1. What is the correct approach please?
I later got AC with this algorithm, it was correct as I had expected. What I did was use double for the points' coordinates and output with ".6f" as if the were float. Why does that work and my other version doesn't? Input: 2 1 1 Output 1: 1 -1 3 Output 2: 2 -1 1 1 3 Какой из ответов правильный? If you work in C, just use int64_t for N and it will work! I spend like 2 hours solving bugs just because of datatypes (facepalm) #include <stdio.h> #include <math.h> int foo () { long long int a; while(scanf ("%lld",&a)!=EOF) { foo (); printf ("%.4f\n",sqrt ((double)a)); return 0; } } int main () { foo (); return 0; } )) decided it's need to use double in scanf
Well, I guess there is some sneaky thing. Someone can give me test 4 please. Thanks import java.util.Scanner; public class problem1197 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int I = in.nextInt(); int J = in.nextInt(); if (I == 1) { System.out.println(1); return; } if (I == J) { System.out.println(I); return; } int deyer[] = new int[100001]; int idx = 0; int min = 10000; int mineded = 0; for (int i = J; i >= I; i--) { for (int j = i / 2; j >= 1; j--) { if (i % j == 0) { if (j < min) { min = j; mineded = i; if (j == 1) { System.out.println(i); return; } } break; } } } System.out.println(mineded); } } Very interesting idea but I can't guess why is it always true. Can you give me some explanation on my mail please?! mamuka_sakhelashvili@yahoo.com Thanks! #include <bits/stdc++.h> using namespace std; typedef long long ill; ill arr[250000]; int main() { int n; cin >> n; for(int i = 0; i < n; ++i) cin >> arr[i]; nth_element(arr,arr+n/2,arr+n); double ans = (double)arr[(n/2)];
if (n & 1){ printf("%0.1lf\n",ans); } else { nth_element(arr,arr+(n/2)-1,arr+n); ans += (double)arr[(n/2)-1]; printf("%0.1lf\n",ans/2.0); } return 0; } Can somebody tell me the problem .... |
|
|