时限:1秒 | 内存:32M |
通过:10 | 提交:27 |
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 ......................................
- the n-th line contains n +1 values (begin from line 0)
- for the k-th value in the n-th line(n>=1)
- When k = 1 or k = n +1 its value is 1
- When k! = 1 and k! = n +1 its value is the sum of the k-1th value in the n-1-th line and the k-th value in the n-1-th line
Input
Output
Sample Input
1 1 2 2
Sample Output
1 2 0 2
#include<iostream> using namespace std; int odd(int n,int k) { return k==(n&k); } int main() { int k; long n,sum; while(cin>>n>>k) { printf("%d ",odd(n,k-1)); sum=1; while(n>=2) { sum*=n%2+1; n=n/2; } if(n>0) sum*=n+1; printf("%ld/n",sum);
} return 0; }
好险,时间居然是0.98s,差一点点,呵呵