Is this problem really about counting Connected Labelled Graphs with n vertices and n-1 edges?
I had came up with a permutation which (after factoring the numerator and denominator) ended up being wrong.
Is there any clue for this problem?
Moderator: Board moderators

#include <cstdio>
int getMod(int a,int b,int c){
int i,n = a;
if(a == 1 || a == 2)
return 1;
for(i = 1; i< b; i++){
a *= n;
a %= c;
}
return a%c;
}
int main(){
int b,i,test;
//freopen("in.txt","rt",stdin);
scanf("%d",&test);
for(i = 1;i <= test; i++){
scanf("%d",&b);
printf("Case #%d: %d\n",i,getMod(b,b-2,2000000011));
}
return 0;
}newton wrote:why WA.
please give me some critical input output.
#include<stdio.h>
#include<math.h>
int main()
{
long n,num,i,m,p;
scanf("%ld",&num);
for(int it=0;it<num;it++){
scanf("%ld",&n);
p=n;
if(n==1 || n==2){printf("1\n");continue;}
m=n-2;
for(i=1;i<m;i++){
p=p*n;
p=p%2000000011;
}
printf("%ld\n",p);
}
return 0;
}
Articuno wrote:In this problem your program must have the ability to calculate (100^98)%2000000011. It is not possible with traditional looping.
ans=1;
for(i=1;i<=98;i++)
{
ans=ans*100;
}#include<stdio.h>
#include<math.h>
int main()
{
long N,X,i,m,p,num,ans;
scanf("%ld",&num);
for(int it=0;it<num;it++){
scanf("%ld",&X);
N=X-2;
if(X==1 || X==2){printf("1\n");continue;}
for(i=1;i<=N;i++){
if(i%2==0){
ans=pow(X,(N/2))*pow(X,(N/2));
ans=ans%2000000011;
}
else if(i%2!=0){
ans=X*pow(X,N-1);
ans=ans%2000000011;
}
}
printf("%ld\n",ans);
}
return 0;
}
Users browsing this forum: No registered users and 1 guest