| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
正好1000ms过掉,完全蛮力In Reply To:9XXms~~卡过的飘过~~~~ Posted by:jdx2013519 at 2009-08-09 17:37:51 Problem: 2992 User: huicpc39
Memory: 164K Time: 1000MS
Language: C Result: Accepted
Source Code
#include <stdio.h>
int p[83]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,
317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431};
int cal(int k,int base){
int s=0;
while(k){
s+=k%base;k/=base;}
return s;}
int main(){
int n,k,s1,s2,s,i;
__int64 res;
while(scanf("%d%d",&n,&k)!=EOF){
res=1ll;
for(i=0;i<83&&n>=p[i];++i){
s1=cal(k,p[i]);
s2=cal(n-k,p[i]);
s=cal(n,p[i]);
res*=(s1+s2-s)/(p[i]-1)+1;}
printf("%I64d\n",res);}
return 0;}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator