Common Board#include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } 5 600 600 600 600 600 Thank you!!! #include<iostream> #include<algorithm> using namespace std; int main() { int i,n,a[155],k=0; cin>>n; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n+1); for(i=0;i<n;i++) if(a[i]==a[i+3]) k++; cout<<k; return 0; } look at my test .... use your program 10 600 600 600 600 600 600 600 600 600 600 I think your answer is 7... But true answer is 2! Edited by author 26.05.2013 09:50 Sorry, but true answer is 1, on my opinion Edited by author 04.12.2014 17:01 Edited by author 04.12.2014 17:02 5 600 600 600 600 600 what is the answer for this test? my programm writes 1 isn't it right?? I construct vertical blocks made of bricks. Now, blocks are of height 1,2,3,...n-1. Now, to make these many i need n*(n-1)/2 bricks. But, I have n bricks so I have to remove former minus latter number of bricks, which is n(n-3)/2. Now, the problem can be changed to number of ways of obtaining n(n-3)/2 from numbers 1,2,3,...n-1 while each number can be used only once. If you find the approach to be correct, please tell me how to obtain this number.(I am a newbie in coding..:)). Let me know please, why i should not think in this way - i have A ways to make n-1 strip sequences. If i will add red or white strip from the left side, i have A ways to make n strip sequences. R/W + [n-1.....] But in the same time i can add red or white strip from the right side, and so i'll have another A ways to make n strip sequences. [n-1....] + R/W So, now i have 2*A ways to make n strip sequences. What's wrong in this kind of argumentation ? Some ways may be counted twice, so the ways will be less than 2A so what is the trick with the test 13? Here is my code: public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); long[] arr = new long[k]; long first = 20000000000000L; int first_location = 0; long second = 2000000000000L; for (int i = 0; i < k; i++) arr[i] = input.nextInt();
for (int i = 0; i < k; i++) if (arr[i] < first) { first = arr[i]; first_location = i; } arr[first_location] = 0;
for (int i = 0; i < k; i++) if (arr[i] < second && arr[i] != 0) second = arr[i]; long answer = first + second - n; if (answer > 0) System.out.println(answer); else System.out.println(0);
} var a:array[1..20] of integer; n,n1:string; x,k,i,s,code:integer; begin read(n); x:=length(n); k:=x div 3; if x mod 3>0 then k:=k+1; for i:=1 to k do begin n1:=copy(n,x-3*i+1,3); val(n1,k,code); a[i]:=k; delete(n,x-2*i,3); end; k:=x div 3; if x mod 3>0 then k:=k+1; if k div 2=0 then begin a[1]:=-1*a[1]; a[3]:=-1*a[3]; a[5]:=-1*a[5]; a[7]:=-1*a[7]; a[9]:=-1*a[9]; a[11]:=-1*a[11]; a[13]:=-1*a[13]; a[15]:=-1*a[15]; a[17]:=-1*a[17]; end else begin a[2]:=-1*a[2]; a[4]:=-1*a[4]; a[6]:=-1*a[6]; a[8]:=-1*a[8]; a[10]:=-1*a[10]; a[12]:=-1*a[12]; a[14]:=-1*a[14]; a[16]:=-1*a[16]; end; for i:=1 to 17 do s:=s+a[i]; write(abs(s mod 7)); end. TIME Memory Suffix array - 0.031 s 534 kb Z-function - 0.187 s 132 kb Edited by author 03.12.2014 15:29 My algo is to check that: 1) all spins done in same side 2) all sides are equal 3) all angles are equal 4) in any comparsions precision equals 0.000001 (I tried many variants of precision but got WA12 in any case) It's hard for me to find tests in this problem :( What the hell is 12 test? Edited by author 04.10.2012 12:13 make sure every edge longer than 1e-6 #include <stdio.h> int main() { long int n, id[150000], m[150000], max, x, i, j; while(scanf("%ld", &n)==1) { for(i=0; i<n; i++) { scanf("%ld %ld", &id[i], &m[i]); } for(i=0; i<n; i++) { max=0; for(j=0; j<n; j++) { if(m[j]>max) { max=m[j]; x=j; } } printf("%ld %ld\n", id[x], max); m[x]=0; } } return 0; } I don't understand the sample. Or I should say I don't understand the meaning of the problem... :( First brushstroke has a point of turn in (0, 1), second - in (2, 1), thrid - in (1, -1), fourth - in (2.5, 0.5). Hope, now you will understand. Thank you very much! I've got accepted with this knowledge:) Why can't the third brushstroke be in (1, 1)? In this case the frame will be smaller, won't be? Why can't the third brushstroke be in (1, 1)? In this case the frame will be smaller, won't be? It said, "90 degrees clockwise". And it would have been much harder. =) Edited by author 01.12.2014 08:39[code deleted] Edited by moderator 29.01.2022 19:09 Try this test case: 5 5 8 13 14 15 correct answer = 1 split = 5 8 14 | 13 15 sum = 27 | 28 #include <iostream> #include <math.h> #include <vector> #include <stdio.h> using namespace std; int main() { unsigned long long a; vector<unsigned long long> b; cin.clear(); while(cin>>a,!cin.eof()) { b.push_back(a); } for(vector<unsigned long long>::iterator it = b.begin() ; it != b.end(); ++it) { printf("%.4lld\n", sqrt(*it)); } return 0; } Edited by author 23.05.2014 07:23 Edited by author 23.05.2014 07:23 It seems that you print numbers to right order, you should print them to reverse order. Like this: for (vector<...> : reverse_iterator it = b.rbegin(); it != b.rend(); ++t) ... what's that means? Output limit exceeded. I have got ac by return NO when k > 20, but how to prove it? #include <iostream> #include <math.h> using namespace std; const long double D=6875; const long double pi=3.1415926535897932384626433; struct postype{ long double x,y,z; }; int x1,x2,x3,yy1,y2,y3; int sx1,sx2,sx3,syy1,sy2,sy3; char str[100000]; char xstr[10],ystr[10],sxstr[10],systr[10]; postype ship,ice; long double angle1,angle2;
long double dis(double a,double b,double c,double d,double e,double f){ a-=d; b-=e; c-=f; return sqrt(a*a+b*b+c*c); }
int main(){ for (int i=1;i<=3;++i) gets(str); scanf("%d^%d'%d\" %s\n",&x1,&x2,&x3,&xstr); scanf("and %d^%d'%d\" %s\n",&yy1,&y2,&y3,&ystr); gets(str); scanf("%d^%d'%d\" %s\n",&sx1,&sx2,&sx3,&sxstr); scanf("and %d^%d'%d\" %s\n",&syy1,&sy2,&sy3,&systr); gets(str);
double a=x1,b=x2,c=x3; angle1=a*3600+b*60.0+c; angle1/=3600.0*180; angle1*=pi; if (xstr[0]=='S') angle1=-angle1; a=yy1;b=y2;c=y3; angle2=a*3600+b*60.0+c; angle2/=3600.0*180; angle2*=pi; if (ystr[0]=='W') angle2=-angle2; ship.x=D/2*cos(angle1)*cos(angle2); ship.y=D/2*cos(angle1)*sin(angle2); ship.z=D/2*sin(angle1);
a=sx1,b=sx2,c=sx3; angle1=a*3600+b*60+c; angle1/=3600.0*180; angle1*=pi; if (sxstr[0]=='S') angle1=-angle1; a=syy1;b=sy2;c=sy3; angle2=a*3600+b*60+c; angle2/=3600.0*180; angle2*=pi; if (systr[0]=='W') angle2=-angle2; ice.x=D/2*cos(angle1)*cos(angle2); ice.y=D/2*cos(angle1)*sin(angle2); ice.z=D/2*sin(angle1);
long double linedis=dis(ship.x,ship.y,ship.z,ice.x,ice.y,ice.z); linedis/=2; long double AA=asin(linedis*2/D)*2; long double ans=AA; ans=ans*D/2;
printf("The distance to the iceberg: "); cout.precision(2); cout<<fixed; cout<<ans; printf(" miles.\n"); if (100.00-ans>0.005) printf("DANGER!"); } I got accepted, but my program dont work on test: 1 1 3 3 2 2 1 correct answer - 0 0.41 my program write - 0.41 0.41 please rejudge Edited by author 21.08.2008 16:27 Edited by author 12.07.2009 05:14 Thanks, your test helps me to get AC :) |
|