AtCoder Typical Contest 002

Submission #6901863

Source codeソースコード

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long b,p,k,s,t;
int main()
{
    cin>>b>>p>>k;
    cout<<b<<"^"<<p<<" mod "<<k<<"=";
    s=b%k;
    t=1;
    for (int i=2;i<=p;i++)
    {
        s=s*b%k;
        if (s==b%k) break;
        t++;
    }
    p=p%t;s=1;
    if (p==0) p=t;
    for (int i=1;i<=p;i++)
    s=s*b%k;
    cout<<s;
    return 0;
}

Submission

Task問題 B - n^p mod m
User nameユーザ名 luogu_bot4
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 407 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample -
All 0 / 100 001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,019.txt,020.txt,021.txt,022.txt,023.txt,024.txt,025.txt,026.txt,027.txt,sample_01.txt,sample_02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
001.txt WA
002.txt WA
003.txt WA
004.txt WA
005.txt WA
006.txt WA
007.txt WA
008.txt WA
009.txt WA
010.txt WA
011.txt TLE
012.txt TLE
013.txt TLE
014.txt TLE
015.txt TLE
016.txt WA
017.txt TLE
018.txt TLE
019.txt TLE
020.txt TLE
021.txt WA
022.txt WA
023.txt WA
024.txt WA
025.txt WA
026.txt WA
027.txt WA
sample_01.txt WA
sample_02.txt TLE