ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1110. Power

Who knows what is WA 6?! my program works correctly I think!
Posted by Nęmø..! 20 Jan 2011 20:23
c++:


#include<iostream>
using namespace std;

long long sqr(int x, int y){
    long long a=1;
    for(int i=1;i<=y;i++)
            a*=x;
    return a;
}

int main(){
    int n,y,m,a=-1;
    cin>>n>>m>>y;
    if(y>=m){
           cout<<-1<<endl;
           return 0;
    }
    for(int x=0;x<m;x++)
            if((sqr(x,n))%m==y){
                                cout<<x<<" ";
                                a+=2;
            }
    cout<<endl;
    if(a==-1 && y<m)
             cout<<-1<<endl;
    return 0;
    }

please help me!

Edited by author 20.01.2011 20:31

Edited by author 20.01.2011 20:33
Re: Who knows what is WA 6?! my program works correctly I think!
Posted by Ahmad 21 Apr 2011 15:13
You should include math libarary
like <math.h> or <cmath>
Re: Who knows what is WA 6?! my program works correctly I think!
Posted by Nęmø..! 30 Aug 2011 19:48
Of course not! I've coded function sqr!
Re: Who knows what is WA 6?! my program works correctly I think!
Posted by CLearER 7 Dec 2012 12:35
Problem is in "long long int" - not enough for 998^999
Re: Who knows what is WA 6?! my program works correctly I think!
Posted by Lochinbek_Boboyev_TUIT 7 Dec 2012 17:52
Use BigInteger