|
|
Common Board#include <iostream> #include <vector> #include <iomanip> #include <cmath> using namespace std; int main (){ double Input=0 ; double number[] ; int counter=0; while ( cin >> Input && Input != EOF){ number[counter] = Input; cout << number[counter]; counter++ ; } for (int i=counter ; i>0; i--){ cout << setprecision(4) << sqrt (number[counter]) << endl; } } #include <bits/stdc++.h> using namespace std; signed main(){ int n; cin>>n; int sum=0; for(int i=0;i<n;i++){ int x; cin>>x; sum+=x; } double cnt1=(double)sum/(double)n; if(cnt1==3){ cout<<"None"; }else if(cnt1==5){ cout<<"Named"; }else if(cnt1>=4.5 && cnt1!=5){ cout<<"High"; }else if(cnt1!=3 && cnt1!=5 && cnt1<4.5){ cout<<"Common"; } } getting a wrong answer on test 8 i use clear binmask as in 1122, but in 1122 u can chek for answer your board by every change of bit, BUT in THIS problem, u need check board when you finish your changes with bits. Example u have bits 1101 and next is 1110, u firstly change 1111 and then 1110 (two iterations because we need to do this iterations on board) so if u do check on every that iteration its wa19 On test bwwb bbwb bwwb bwww My program gives 3, but right ans is 4 this test from 1060 //Input: 12 10 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 2 3 1 1 1 0 0 0 0 0 2 4 2 0 0 0 0 0 0 0 0 2 3 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 //Correct output: WWWWW WRWWW WWRWW WWWWW WWWWW WWWWW WRRW WRWW WWWW WWWW WWWW RWW WWW WWW WWW RW WW WW W W Another one: 8 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 It's written that the numbers don't exceed 15000, but it's most likely that the test 2 contains number 15001, cuz i was receiving WA until i changed border to 163847 (is 15001st prime number) Could anybody help me? I have WA at 3th test .I tried many test and answers were correct .I also tried this test and answer was correct: 5 -5 0 0 1 1 2 2 3 4 5 3 4 10 49000 0 0 The only formulas you need is a distance between two points to find the answer and a distance between point and a line to check if answer exists For every pair of points, build circles on them and find their collision points(<= 2). Then for every collision point find number of points on distance < r to it. Maximum is the answer #include <stdio.h> int main() { int t1,t2,n; int c=0; scanf("%d %d", &t1, &t2); for (int i=0; i<=9; i++) { scanf("%d", &n); c+=(n*20); } t2-=c; if (t2<t1) { printf("Dirty debug :("); } else { printf("No chance."); } } Если я не ошибаюсь, вам стоит подключить пространство имён. using namespace std; Any help? In WA5 X=Y and thus the answer should be "0" If you have WA 13, try this test: 1 a 1 b....ba , where b repeated ~130000 times If you've got rte 27: m can be more than 10000 With help of my friend that was just looking at maximums index sequense and found an idea, finally, I got AC. Some hints: 1) Find an idea to calculate next maximum indices from previous ones: all the maximum's indices can be obtained from previous ones in such ways: i = s*2 + 1; or i = s*2 - 1; or i = s*4 + 1; or i = s*4 - 1; for example f(21)=8 is maximum for 21<=n<=34 so 21 = 2*11-1, where 11 is one of previous maximums indices. And so on using all the formulas above. but 2*11+1 = 23 is not a maximum index. so we have to cancel this number (23). 2) Learn to calculate f(n) in O(logn) 3) Generate all maximums indices (about 1500). You can store them in heap to get an access to the smallest maximum index. 4) than read n and just search for it in maximums index array. P.S. who can prove the first and the main idea? If you can, please post here you proof. How did you invent it? Edited by author 05.07.2009 22:51 It seems that only test s*2 - 1 and s*4 - 1 is OK. I've tested by bruteforce program in range [0, 20000000]. I will try it. Edited by author 15.10.2016 08:24 This is exactly how my accepted program runs. Suppose i is a maximum index, i = 2*i1+1, i2 = i1+1, then either 1) i1 is even, at least one of i1/2, i2 is a maximum index; or 2) i2 is even, at least one of i2/2, i1 is a maximum index. But I don't know how to prove it. Thus candidate indices from 2^n to 2^{n+1} can be generated from calculated maximum indices from 2^{n-2} to 2^n. You only have four things to pick from, so you can calculate each step explicitly. This equation follows the notation in the article: T is the time to collect all of the items, and ti be the time to collect the i-th item after i−1 items have been collected. E(T)=E(t1)+E(t2)+E(t3)+E(t4)=p1−1+p2−1+p3−1+p4−1. The probability p1 of picking a new one if you have picked none yet is 1. The probability p2 of picking a new one if you have picked one depends on which one you picked first. Let's call the items A through D and the probabilities of picking each item if they're all in the box pa through pd. Then p2 would be pa(pb+pc+pd)+pb(pc+pd+pa)+pc(pd+pa+pb)+pd(pa+pb+pc). The above expression is the probability of picking a new one given that A had been picked already, plus the probability of picking a new one given that B had been picked already, and so on. The expression for p3 will have six terms in the sum; one of these will be papb(pc+pd). The expression for p4 will have four terms in the sum (actually, it's the same term four times!) What can I do?.. My program passes all testes here, but still WA12... Any test cases? it takes a lot of my times. #include<iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << b-1 << ' ' << a - 1; } 4 2 2 3 2 1 3 3 1 2 4 1 3 6 5 2 3 4 5 6 5 1 3 4 5 6 5 1 2 4 5 6 5 1 2 3 5 6 5 1 2 3 4 6 5 1 2 3 4 5 8 7 2 3 4 5 6 7 8 7 1 3 4 5 6 7 8 7 1 2 4 5 6 7 8 7 1 2 3 5 6 7 8 7 1 2 3 4 6 7 8 7 1 2 3 4 5 7 8 7 1 2 3 4 5 6 8 7 1 2 3 4 5 6 7 6 2 2 3 2 1 3 2 1 2 2 5 6 2 4 6 2 4 5 |
|
|