zoukankan      html  css  js  c++  java
  • light OJ 1282

    http://lightoj.com/volume_showproblem.php?problem=1282

    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <assert.h>
    #define IOS ios::sync_with_stdio(false)
    using namespace std;
    #define inf (0x3f3f3f3f)
    typedef long long int LL;
    
    
    #include <iostream>
    #include <sstream>
    #include <vector>
    #include <set>
    #include <map>
    #include <queue>
    #include <string>
    #include <bitset>
    
    
    //int calc(LL a, LL b, int k) { //a^b的前k + 1位
    //    double res = b * log10(a * 1.0) - (LL)(b * log10(a * 1.0)); //小数部分
    //    return (int)pow(10.0, k + res);
    //}
    int calc(double a, LL b, int k) {
        double ans = 1, base = a;
        while (b) {
            if (b & 1) {
                ans = ans * base;
            }
            b >>= 1;
            base = base * base;
            while (ans >= 1000) ans /= 10; //保留前3位
            while (base >= 1000) base /= 10;
        }
        return (int)ans;
    }
    int quick_pow(LL a, LL b, int MOD) {
        LL ans = 1, base = a % MOD;
        while (b) {
            if (b & 1) ans = ans * base % MOD;
            b >>= 1;
            base = base * base % MOD;
        }
        return ans;
    }
    void work() {
        LL a, b;
        cin >> a >> b;
        static int f = 0;
        printf("Case %d: %d %03d
    ", ++f, calc(a, b, 3), quick_pow(a, b, 1000));
    }
    
    int main() {
    #ifdef local
        freopen("data.txt", "r", stdin);
    //    freopen("data.txt", "w", stdout);
    #endif
        int t;
        scanf("%d", &t);
        while (t--) work();
        return 0;
    }
    View Code
  • 相关阅读:
    线性dp 打鼹鼠
    区间dp 能量项链 洛谷p1063
    洛谷 CF1012C Hills (动态规划)
    交作业了 动态规划 木棍加工
    最短路之Floyd
    最小生成树
    寒假集训并查集初级版
    【倍增DP】——保卫王国
    bootstrap四部分概述
    zrender初识
  • 原文地址:https://www.cnblogs.com/liuweimingcprogram/p/6583154.html
Copyright © 2011-2022 走看看