https://vjudge.net/problem/SPOJ-LASTDIG

求最后一位,%10就完了

这个题居然要求代码小于等于700B

#include <iostream>
#include <cstdio>
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i) using namespace std;
long long T,n,x,y; long long ksm(long long a,long long b){
long long r=;
while(b>){
if(b&)
r=r*a%;
a=a*a%;
b>>=;
}
return r;
} int main(){
cin>>T;
while(T--){
cin>>x>>y;
cout<<ksm(x,y);p('\n');
}
return ;
}

SPOJ - The last digit的更多相关文章

  1. SPOJ #5 The Next Palindrome

    "not more than 1000000 digits" means an efficient in-place solution is needed. My first so ...

  2. SPOJ BALNUM - Balanced Numbers - [数位DP][状态压缩]

    题目链接:http://www.spoj.com/problems/BALNUM/en/ Time limit: 0.123s Source limit: 50000B Memory limit: 1 ...

  3. BZOJ 2588: Spoj 10628. Count on a tree [树上主席树]

    2588: Spoj 10628. Count on a tree Time Limit: 12 Sec  Memory Limit: 128 MBSubmit: 5217  Solved: 1233 ...

  4. [LeetCode] Nth Digit 第N位

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...

  5. [LeetCode] Number of Digit One 数字1的个数

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less th ...

  6. SPOJ DQUERY D-query(主席树)

    题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...

  7. [Leetcode] Number of Digit Ones

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less th ...

  8. SPOJ GSS3 Can you answer these queries III[线段树]

    SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...

  9. 【Codeforces715C&716E】Digit Tree 数学 + 点分治

    C. Digit Tree time limit per test:3 seconds memory limit per test:256 megabytes input:standard input ...

随机推荐

  1. Spark 调优之ShuffleManager、Shuffle

    Shuffle 概述 影响Spark性能的大BOSS就是shuffle,因为该环节包含了大量的磁盘IO.序列化.网络数据传输等操作. 因此,如果要让作业的性能更上一层楼,就有必要对 shuffle 过 ...

  2. Codeforces 1154B Make Them Equal

    题目链接:http://codeforces.com/problemset/problem/1154/B 题意:给定数组,可以给任意的的元素加上D 或者 减去D,如果能 使数组元素都相等,输出最小的D ...

  3. Codeforces 1167A-Telephone Number

    题目链接:http://codeforces.com/problemset/problem/1167/A 思路:检索前面0 ~(n −11)个字符中是否有 8 即可. AC代码: #include&l ...

  4. USACO2012 Haybale stacking /// 区间表示法 oj21556

    题目大意:N个方块 标号1~N  K个操作 操作a b 表示标号a~b区间每位多加一个方块 Input * Line 1: Two space-separated integers, N  K. * ...

  5. python opencv3 写字画圈画矩形

    python opencv练习 自定义一张[512, 512, 3]的图像 在上面写写字,画画圈和矩形 显示 代码为: import cv2 import numpy as np img = np.z ...

  6. Python全栈开发:django网络框架(一)

    Python的WEB框架有Django.Tornado.Flask 等多种,Django相较与其他WEB框架其优势为:大而全,框架本身集成了ORM.模型绑定.模板引擎.缓存.Session等诸多功能. ...

  7. js拼接HTML onclick传参,,页面转义符

    字符串 1 使用" .比如: ("'+key+'")例: htmlStr = htmlStr + '<span><img src="'+src ...

  8. merge存储引擎基本介绍和使用规范说明

    [以下两段截自MySql手册]: merge存储引擎,也被认识为mrg_myisam引擎,是一个"相同“的表可以被当作一个表来用的myisam表的集合.“相同”意味着所有表同样的列和索引信息 ...

  9. leetcode-63-不同路径②

    题目描述: 第一次提交: class Solution: def uniquePathsWithObstacles(self, obstacleGrid) : m = len(obstacleGrid ...

  10. webpack官方文档学习

    一.webpack是什么? webpack是一款模块加载器兼打包工具,它能把各种资源,例如JS(含JSX).coffee.样式(含less/sass).图片等都作为模块来使用和处理. 二.安装 前提条 ...