标签:des style blog http io ar color os sp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6084 Accepted Submission(s): 2222
HDU 1041 、找规律+大数
import java.util.*; import java.math.*; public class Main { public static void main(String argc[]) { Scanner cin=new Scanner(System.in); int n,i; BigInteger a[]=new BigInteger [1005]; BigInteger c=new BigInteger("2"); a[1]=new BigInteger("0"); a[2]=new BigInteger("1"); for(i=3;i<=1000;i++) { a[i]=a[i-2].multiply(c).add(a[i-1]); } while(cin.hasNext()) { n=cin.nextInt(); System.out.println(a[n]); } } }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31541 Accepted Submission(s): 12610
#include <iostream> #include <cstdio> using namespace std; #define ll __int64 int main() { int n,i; ll q[52]; q[1]=3; q[2]=6; q[3]=6; for(i=4;i<=50;i++) { q[i]=2*q[i-2]+q[i-1]; } while(scanf("%d",&n)!=EOF) { printf("%I64d\n",q[n]); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 21737 Accepted Submission(s): 10202
#include <iostream> #include <cstdio> using namespace std; int main() { int n; __int64 q[42]={0,3,8}; for(int i=3;i<40;i++) { q[i]=2*(q[i-1]+q[i-2]); } while(scanf("%d",&n)!=EOF) { printf("%I64d\n",q[n]); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32075 Accepted Submission(s): 16540
#include<iostream> #include<cstdio> using namespace std; int a[41]; void Find() { a[1]=1; a[2]=2; for(int i=3;i<=40;i++) { a[i]=a[i-1]+a[i-2]; } } int main() { int T,n; Find(); scanf("%d",&T); while(T--) { scanf("%d",&n); cout<<a[n-1]<<endl; } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 30647 Accepted Submission(s): 14837
#include <iostream> #include <cstdio> using namespace std; #define ll __int64 int main() { int n; ll q[52]; q[1]=1; q[2]=2; for(int i=3;i<=50;i++) { q[i]=q[i-1]+q[i-2]; } while(scanf("%d",&n)!=EOF) { printf("%I64d\n",q[n]); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23029 Accepted Submission(s): 8451
#include <iostream> #include <cstdio> using namespace std; #define ll __int64 ll C(ll n,ll m) { if(m==0) return 1; return C(n,m-1)*(n-m+1)/m; } int main() { int n,m,i,T; ll q[22]; q[0]=1; q[1]=0; for(i=2;i<=20;i++) { q[i]=(i-1)*(q[i-2]+q[i-1]); } scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); printf("%I64d\n",q[m]*C(n,n-m)); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 45118 Accepted Submission(s): 22390
HDU 2018
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define ll long long #define N 55 ll a[N+2]; int main() { int i,n; a[1]=1; a[2]=2; a[3]=3; for(i=4;i<55;i++) { a[i]=a[i-3]+a[i-1]; } while(cin>>n && n) { cout<<a[n]<<endl; } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23655 Accepted Submission(s): 9896
HDU 2048 错排
#include <iostream> #include <cstdio> using namespace std; #define ll __int64 int main() { int n,i,T; ll q[22]; q[0]=1; q[1]=0; for(i=2;i<=20;i++) { q[i]=(i-1)*(q[i-2]+q[i-1]); } scanf("%d",&T); while(T--) { scanf("%d",&n); ll ans1=q[n]; ll ans2=1; for(i=1;i<=n;i++) { ans2*=i; } printf("%.2f%%\n",q[n]*1.0/ans2*100); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 41359 Accepted Submission(s): 15106
HDU 2044 斐波拉契
#include <iostream> #include <cstdio> #include <cmath> using namespace std; #define ll __int64 int main() { int T; ll q[52]; q[1]=1; q[2]=2; for(int i=3;i<50;i++) { q[i]=q[i-1]+q[i-2]; } scanf("%d",&T); while(T--) { int a,b,c; scanf("%d%d",&a,&b); c=abs(b-a); printf("%I64d\n",q[c]); } return 0; }
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 17520 Accepted Submission(s): 12085
HDU 2050
#include <iostream> using namespace std; int main() { int n,T; cin>>T; while(T--) { cin>>n; cout<<2*n*n-n+1<<endl; } return 0; }
标签:des style blog http io ar color os sp
原文地址:http://www.cnblogs.com/hate13/p/4121420.html