[HDU] [1097] A hard puzzle

Problem Description

Loading...

Problem Analysis

A pattern-finding problem
By the way, the upload order seems off…
This one was written later
But none of that matters

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include<stdio.h>
int main() {
    int i,a,b,m;
    while(scanf("%d %d",&a,&b)!=EOF) {
        a=a%10;
        b=b%4;
        if(b==0)
            b=4;
        for(i=0,m=1; i<b; i++)
            m=(m*a)%10;
        printf("%d\n",m);
    }
    return 0;
}

Loading...