Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

C式C++ 较短代码

Posted by 602651749 at 2019-09-09 23:38:00 on Problem 1906 and last updated at 2019-09-10 00:03:05
#include <stdio.h>

unsigned long long N=1000000000000000LL,in,
  d[25][2]={{665459056928801LL,12157}},d2[40]={1};

int main(){
    int t,f;
    for(int i=1;i<25;++i){
    	d[i][0]=(d[i-1][0]*3)%N;
    	d[i][1]=d[i-1][0]*3/N+d[i-1][1]*3;
    }
    for(int i=1;i<40;++i){
    	d2[i]=d2[i-1]*3;
    }
    while(1){
	scanf("%llu",&in);
	if(in==0) break;
	if(in==1) {printf("{ }\n");continue;}
	printf("{ ");
	in-=1;
	t=f=0;
	while(in!=0){
	    if(in&1) {
		if(!f) f=1;
		else printf(", ");
		if(t<40) printf("%llu",d2[t]);
		else printf("%llu%015llu",d[t-40][1],d[t-40][0]);
	    }
	    in>>=1;
	    t++;
	}
	printf(" }\n");
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator