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

Weird

Posted by ACMTino at 2006-09-30 02:25:22 on Problem 3012
I suspected that Judge has some bug in it.

if I change 
**************************************************
                  t=n;
		count=0;
		while(n) {
			b[count++]=n%2;
			n/=2;
		}
**************************************************
to
                  t=n;
		count=0;
		while(t) {
			b[count++]=t%2;
			t/=2;
		}

it would get accepted

please check it, thanks
ACMTino



#include<stdio.h>
#include<stdlib.h>

main() {
	__int64 i,j,cases;
	__int64 n,k,m,t,count,result;
	bool b[50];
	
	scanf("%I64d",&cases);
	while(cases--) {
		scanf("%I64d %I64d %I64d",&n,&k,&m);

		t=k;
		count=0;
		while(t) {
			b[count++]=t%2;
			t/=2;
		}
		t=10;
		result=1;
		for(i=0;i<count;++i) {
			if(b[i]) result=(result*t)%m;
			t=(t*t)%m;
		}
		result=(result+1)%m;
		
		t=n;
		count=0;
		while(n) {
			b[count++]=n%2;
			n/=2;
		}
		
		t=result;
		result=1;
		for(i=0;i<count;++i) {
			if(b[i]) result=(result*t)%m;
			t=(t*t)%m;
		}
		printf("%I64d\n",result);
	}
}

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