Common BoardHi everybody. Give me some test for this task, please. Cause I check it on my PC-it's working good(everything is finding), but when I want send it to check->"Wrong Answer" Или, кто может подсказать возможные ошибки? Edited by author 15.09.2011 19:00 You can use BigDecimal constructor for checking the validity of number. After some preprocessing to the realnumber String. Good luck. So I will answer myself, This test helped me: 5 2 5 0 3 0 4 0 5 0 0 Maybe it isn't exactly the same test as #6 but i hope that it will help you too.. Good Luck! in the 6th test coloring is impossible 74 authors lost AC after rejudge. I believe the tests are still weak. My solution which answers with "110...0" to "4 4", "5 6", "7 14", "8 22" got Accepted. Edited by author 15.09.2011 03:00 Edited by author 15.09.2011 03:00 I've added these tests, but you seem to be the only author who doesn't pass them. :) give me some hints please.. try to consider that initially the ojbect was at an odd (or even) place the algo is very easy. i spent 2 minutes solving this problem. try to find steps for n=3,4,5 without computer, using pen and sheet of paper. you will see the way) PS poor english, i know Just solve the problem for the case when the dodec. is on even place initially. I got wa on test 2 I want to know if input is : 2 2 what should I output? sorry my English is very poor //WHY #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int main(){ int n=0; //scanf("%d",&n); char c[25]; //scanf("%c",c); int p=0; gets(c);//printf("%c",c[0]); int x=0,y; if(c[1]==' '){y=2;n=c[0]-48;} else {y=3;n=10;}
int l=strlen(c); for(x=y;x<l;x++)if(c[x]==c[y])p++; int ans=1; while(n>=(n+p)%p){ans*=n;n-=p;} printf("%d",ans); // system("pause"); return 0; } //Accepted #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; int main(){ int n=0; //scanf("%d",&n); char c[25]; //scanf("%c",c); int p=0; gets(c);//printf("%c",c[0]); int x=0,y; if(c[1]==' '){y=2;n=c[0]-48;} else {y=3;n=10;}
int l=strlen(c); for(x=y;x<l;x++)if(c[x]==c[y])p++; int ans=1; while(n>=(n+p)%p&&n>0){ans*=n;n-=p;} printf("%d",ans); // system("pause"); return 0; } This is my code... import java.util.Scanner; public class T_1562 { public static double a,b; public static void main(String[] args) { Scanner sc= new Scanner(System.in); a = sc.nextDouble(); b = sc.nextDouble(); b = b/2; a = a/2; int n = sc.nextInt(); double step = 2*b/n; double x = -b; while(x+step <= b){ System.out.printf("%.6f",Math.abs(F(x)-F(x+step))); System.out.println(); x = x+step; } } private static double F(double z){ return Math.PI*(a/b)*(a/b)*(b*b*z - z*z*z/3); } } Edited by author 12.09.2011 14:14 Here's my code that runs well on my PC. #include<iostream> #include<algorithm> using namespace std; main() { string txt; string txtRev; string tmp; int i; int com; while(cin>>txt){ i=0; do{ for (int n=i+2;n<txt.length();n++){ tmp=txt.substr(i,n); txtRev=tmp; reverse(txtRev.begin(),txtRev.end()); com= txtRev.compare(tmp); if (com==0) break; } i++; }while (com!=0); cout<< tmp <<" " <<endl; } } Hi guys, I am trying to solve this problem. But I am not able to understand the the Input and Output which was given. Can anyone help me in understanding the problem, I possible please send me the code. Email: korapatimanoj@gmail.com Thanks in advance... Regards, Manu Hi guys, Even I am trying to solve this problem. But I am not able to understand the the Input and Output which was given. Can anyone help me in understanding the problem, I possible please send me the code. Email: mnjsmitha@gmail.com Thanks in advance... Regards, Manju What is in test 9? there is my code, its get WA on 9th test: #include <iostream.h> __int64 inline linea(long x1i,long y1i,long x2i,long y2i) {return y2i-y1i;} __int64 inline lineb(long x1i,long y1i,long x2i,long y2i) {return x1i-x2i;} __int64 inline linec(long x1i,long y1i,long x2i,long y2i) {return y1i*x2i-x1i*y2i;} int main() { const long con=20000; long n,i,j,k,p1,p2; long x[con],y[con]; __int64 a,b,c; cin>>n; p1=0;p2=1; for (i=1;i<n+1;i++){cin>>x[i]>>y[i];} for (i=1;i<n+1;i++) { if (p1==p2){break;} for (j=i+1;j<n+1;j++) { p1=0;p2=0; a=linea(x[i],y[i],x[j],y[j]); b=lineb(x[i],y[i],x[j],y[j]); c=linec(x[i],y[i],x[j],y[j]); for (k=1;k<i;k++) { if (-b*y[k]>=a*x[k]+c){p1++;} if (-b*y[k]<=a*x[k]+c){p2++;} } for (k=i+1;k<j;k++) { if (-b*y[k]>=a*x[k]+c){p1++;} if (-b*y[k]<=a*x[k]+c){p2++;} } for (k=j+1;k<n+1;k++) { if (-b*y[k]>=a*x[k]+c){p1++;} if (-b*y[k]<=a*x[k]+c){p2++;} } if (p1==p2) {cout<<i<<" "<<j;break;} } } return 0; } Can anybody help me? long x[con],y[con] -> long long :), but you can get tle in 14 :P I don't understand,it should be TLE. RT~~ A simple problem , think carefully~ test 10? And how can i watch the wrong answered tests? Edited by author 13.09.2011 00:50 17 WEARECHAMPIONSYES WEHAVECHAMPIONSNO What should I write in this case ??? Sory my english Edited by author 10.04.2011 23:15 Edited by author 10.04.2011 23:16 Hello! This is listing of my class import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class q1496 { /** * @param args * @throws IOException * @throws NumberFormatException */ public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int amount = Integer.parseInt(in.readLine()); String[] source= new String[amount]; String[] uniT= new String[amount]; int j=0; int count=0; for (int i=0;i<amount;i++) { source[i]=in.readLine(); } Arrays.sort(source); uniT[0]=source[0];
for (int i=0;i<amount;i++) { if (source[i].equals(uniT[j])!=true) { j++; uniT[j]=source[i]; } } for (int i=0;i<=j;i++) { count=0; for (int k=0;k<amount;k++) { if (source[k].equals(uniT[i])) { count++; } } if (count>1){System.out.println(uniT[i]);} } } } Hi there! Look at my approach for solving this problem. I`m using 1-dimensional representation of digital matrix. In example matrix M below: A11, A12, A13, A14 (M) = A21, A22, A23, A24 A31, A32, A33, A34 A41, A42, A43, A44 transforms to the vector V: V = (A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44) (array of integers in my C++ implementation). Than point out the order in which elements of matrix M should appears in result: (1) (3) (6) (10) (2) (5) (9) (13) (4) (8) (12) (15) (7) (11) (14) (16) A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44, where values in brackets are elements serial numbers in result. Onwards take a pencil and draw a curves between elements in desired order: (1) (3) (6) (10) (2) (5) (9) (13) (4) (8) (12) (15) (7) (11) (14) (16) A11, A12, A13, A14, A21, A22, A23, A24, A31, A32, A33, A34, A41, A42, A43, A44 |___↑_|__↑_________↑ | ↑ | ↑ | |_|__|___________| | | | | |__|______________|_|____________| | | |_|______________| |________________| ... and so on In example above 6 elements ordered by curves connections. It should be observed that it`s possible to fix sequence of actions using numeric relative offsets. See below: Step 1) +4 (+4 is offset (in elements) of first element A11); Step 2) -3 (-3 is offset of element, obtained in step 1); Step 3) +7 (+7 is offset of element, obtained in previous step and so on); Step 4) -3 Step 5) -3 Step 6) +10 Step 7) -3 Step 8) -3 Step 9) -3 Step 10) +10 Step 11) -3 Step 12) -3 Step 13) +7 Step 14) -3 Step 15) +4 Halves of steps sequence are simmetrical. Sequence contains two operation type: forward offset and backward offset (all offset are relative). Value of backward always equals to (side of matrix - 1). Value of forward offset different on difference steps. On first and last steps it`s equal to side size. On other steps it`s increased or decreased (above or below of middle steps) on value (side of matrix - 1). Forward steps amount is always equals to 2 x (side-1). Amount of backwards steps are 1 on first forward step, 2 on second and so on toward the middle of iterations. After middle backwards steps amount decreased by 1 on each iterations except last. On last iterations it`s not backwards steps. This algorithm has simple (not required complex data structures) implementation on various language. Thank you for your attention and Good luck! P.S. Sorry for my English =) P.P.S. Graphical representation of algorithms steps is distorted because when message is sent any occurance of double, triple and so on spaces are replaced on one space character :( Edited by author 13.09.2011 15:09 Hi, as I understand, this is a problem on dynamic programming. I see only one solution - go through the whole tree and compute the values for each node from the leaves up to the root of the tree. And on each level the full search should be done. For example, if we want to compute value for a node with p childs with already computed x_1, x_2, .., x_p values, then try 1/p, 2/p, ... p/p as a possible solution for this node. please, give me any hint on this problem. Edited by author 29.03.2011 20:27 Try to think about how the answer for every node (and for the whole tree) depends on x? Use dichitomy (binary search), Luke! ОK, what answer to this test: 106 10 1 1 1 5 1 5 1 5 1 5 2 1 ... 2 1 (70 times: 2 1) 2 100 ... 2 100 (30 times: 2 100) The answer is 80.0000000, but I think, it's incorrect a little bit. Because it is said in the condition "the king needs as many soldiers as possible". If x = 80, then the king will have only 4 soldiers, while if x = 70, the king will have 74 soldiers. So I thought binary search doesn't work there, i.e. the numebr of soldiers is more important, than the total time of preparing to the war (the only thing is necessary is the total time should be not greater than max allowed time). But it's not true. The most important is to maximize the percent in the answer. |
|