Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

HDU 2035 - 人见人爱A^B

$
0
0

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2035

#include <stdio.h>

int mi(int n, int m)
{
    return m?(m%2?(mi(n, m/2)*mi(n, m/2)*(n%1000))%1000:(mi(n,m/2)*mi(n,m/2))%1000):1;
}

int main(void)
{
    int n, m;

    while(scanf("%d%d", &n, &m), n+m)
        printf("%d\n", mi(n, m));
    return 0;
}


#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int i;
    int sum;
    
    while (scanf("%d%d", &a, &b), a || b)
    {
        sum = a;

        for (i = 1 ; i < b ; i++)
            sum = (sum * a) % 1000;

        printf("%d\n", sum % 1000);
    }

    return 0;
}


作者:a1006570862 发表于2013-11-28 1:11:00 原文链接
阅读:82 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>