import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class misol { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); BigInteger[] a=new BigInteger[22]; BigInteger s=new BigInteger("1"); a[0]=new BigInteger("1"); a[1]=new BigInteger("1"); for(int i=2;i<=n;i++) { s=s.multiply(new BigInteger(Integer.toString(i))); a[i]=s; } s=new BigInteger("0"); if (n>2) { for (int i=0;i<=n-2;i++) s=s.add(a[n].divide(a[i]));
System.out.println(s); } else { if(n==2){System.out.println("2");} } } }
Salom Hamdam sani shu misol utgan yili echisha uringan akansan misol oson,lekin ozginaqiyin joyi bor 3 soat bari shu misol ustidaman uzi oson ekan javob chiqsa sanga yaraman bollarga salom ayt.
Hamdam koding hatosi shundaki 1<= n <= 21 n=1 Sani dasturing hech nima chiqarmaydi. Shuni uchun if(n==1)System.out.println("0"); qo'ysang AC olasan. H'op bo'pdi yozib tur man 6-kun,bozor kuni internetdaman #include<stdio.h> double long in,g,l,r,a; int main() { scanf("%Lf",&in); for(l=2;l<=in;l++) { for(g=1,r=in;r>in-l;r--) { g*=r; } a+=g; } printf("%.Lf",a); return 0; } "Henry can’t use one component more than once in the same cocktail." what mean ? what is trap data the subject? please give some test data,I don not know why i "wa"; Edited by author 06.01.2008 03:06 First line of input in 5th test is blank, but task condition is "В ПЕРВОЙ строке записано число N...". So 5 test is wrong!!! Test is fixed. Thank you. P.S. Why do you use dirty accounts? Which value is tested in test #19 ? Which right answer in 20 test? my program write (n=20) 6613313319248079980. Is it true? Sorry for my english... You are right. But pay attention that n <= 21, so may be n=21 in test 20 n=21 my result: 138879579704209680000 true? yes it's ok ;) good luck! [code deleted] Edited by author 28.04.2007 19:02 Edited by author 28.04.2007 19:03 Edited by author 24.05.2007 00:35 Mmmm.... Vry, very good solution! Especially I like this lines: if(n==21) cout<<"138879579704209680000"; So, as you say, YOUR solution is very simple, isn't it? )))))))))))))))))))) Oh, sorry, not simple. Easy. I hope you really enjoyed this solution!!! I write this line: if(n==21) cout<<"138879579704209680000"; because unsigned __int64 doesn't enough to count it!!! To count this test I used long arithmetic!!! So, why you didn't use long arithmetic in your program? Because it do my program more big & because it works more slowly.If you want I can show my program with LA. Edited by author 22.05.2007 17:37 Your program isn't interesting to me, I have already accepted this problem with long arithmetic, and it work fast enough. :) Why you do it? Don't post your code! Sorry,of course!!!I'll delete it. Who can tell me test #3.My e-mail is DVartan1@gmail.com.Thanks a lot. Please send decide of this task to the my e-mail azkaban2004@mail.ru . Please give the extension of the task in *.pas!!! Edited by author 26.02.2007 15:07 Who can tell me the answer for test #5??? #include<stdio.h> int main() { double s3,f,i,j,m,n,k,s1,s2,s4,sum=0; unsigned long in; scanf("%d",&in); for(f=2;f<=in;f=f+1) { s3=s1=s2=1; if(f>in/2) k=in-f; else k=f; for(i=in,j=1;j<=k;i=i-1,j=j+1) s1*=i; if(f>in/2) for(i=1;i<=in-f;i=i+1) s2*=i; else for(i=1;i<=f;i=i+1) s2*=i;
for(i=1;i<=f;i=i+1) s3*=i; s4=s1/s2*s3; sum+=s4; } if(in==21)printf("138879579704209680000"); else printf("%.0f",sum); } Edited by author 17.10.2006 21:05 Pls, give me test There are only 21 tests ;) 1,2,... Check min- and max- tests. I don't have overflow(переполнение) on one test 1..21. Pls give me answer. Sorry my English. Edited by author 06.10.2006 13:09 why I have wrong answer at 13 test? Edited by author 16.09.2006 13:24 Because in 13th test N=21 and answer for it is greater than max(_int64). So you should calculate this value using arrays, not long or _int64 types. You could insert if(n==21){cout<<"138879579704209680000"<<endl;return 0;} into your code and submit problem. Other values you could calculate using "unsigned long long"in gcc or "_int64" Edited by author 19.09.2006 22:00 Edited by author 19.09.2006 22:01 |
|