当前位置:网站首页>1090: integer power (multi instance test)

1090: integer power (multi instance test)

2022-07-07 07:17:00 Huaze flowers

Title Description

seek A^B An integer represented by the last three digits of (1<=A,B<=1000)

Input

n A test case , Each instance gives two positive integers A,B

Output

Output A^B The last three ( There is no forerunner 0)

The sample input

2
2 3
12 6

Sample output

8
984

Code :

// Find the power of an integer ,A^B
// After the output number 3 position 
// Input :
//2
//2 3
//12 6
// Output :
//8
//984



#include <stdio.h>
int main ()
{
    int n;
    scanf("%d",&n);
    int a,b;
    int i,j;
    int sum;
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a,&b);
        sum=1;
        for(j=0;j<b;j++)
        {
            sum*=a;
            while(sum>1000)
            {
                sum=sum%1000;
            }
        }
        printf("%0d\n",sum);
    }
    return 0;
}

Running results :

  Submit :

  But I still have one thing I don't understand , As shown in the following figure , It should be right to write logic like this

  But submit , will not pass

  If that big guy knows , Hope to inform

原网站

版权声明
本文为[Huaze flowers]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130716522392.html