SPOJ - The last digit
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的更多相关文章
- SPOJ #5 The Next Palindrome
"not more than 1000000 digits" means an efficient in-place solution is needed. My first so ...
- SPOJ BALNUM - Balanced Numbers - [数位DP][状态压缩]
题目链接:http://www.spoj.com/problems/BALNUM/en/ Time limit: 0.123s Source limit: 50000B Memory limit: 1 ...
- 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 ...
- [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 ...
- [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 ...
- SPOJ DQUERY D-query(主席树)
题目 Source http://www.spoj.com/problems/DQUERY/en/ Description Given a sequence of n numbers a1, a2, ...
- [Leetcode] Number of Digit Ones
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less th ...
- 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 ...
- 【Codeforces715C&716E】Digit Tree 数学 + 点分治
C. Digit Tree time limit per test:3 seconds memory limit per test:256 megabytes input:standard input ...
随机推荐
- c#种GetType()和TypeOf()的区别
C#中任何对象都具有GetType()方法,它的作用和typeof()相同,返回Type类型的当前对象的类型. typeof(x)中的x,必须是具体的类名.类型名称等,不可以是变量名称:GetType ...
- static 关键字的使用及说明
static 关键字主要有以下几种使用场景: 修饰类的成员变量. 修饰类的成员方法. 修饰类的代码块. 修饰内部类. 1. static 修饰类的成员变量时,被称为静态成员变量.引用 static 修 ...
- L1正则化可以解决过拟合问题(稀疏解)
损失函数最小,也就是求极值点,也就是损失函数导数为0.上面也说了,如果d0+λ和d0-λ为异号的时候刚好为极值点,损失函数导数为0(w为0是条件).而对于L2正则化,在w=0时并不一定是极值点而是d0 ...
- CSS3新属性之---flex box布局实例
flex box布局实例 flex的强大之处在于不管什么布局,几行命令即可实现 /*本节模板div元素(代表骰子的一个面)是Flex容器,span元素(代表一个点)是Flex项目.如果有多个项目,就要 ...
- Spring Boot集成Shiro实战
Spring Boot集成Shiro权限验证框架,可参考: https://shiro.apache.org/spring-boot.html 引入依赖 <dependency> < ...
- python学习8—函数之高阶函数与内置函数
python学习8—函数之高阶函数与内置函数 1. 高阶函数 a. map()函数 对第二个输入的参数进行第一个输入的参数指定的操作.map()函数的返回值是一个迭代器,只可以迭代一次,迭代过后会被释 ...
- scrapy的使用-Request
Request对象在我们写爬虫,爬取一页的数据需要重新发送一个请求的时候调用.这个类需要传递一些参数.其中比较常用的参数有: 1.url 请求的url对象 2.callback 在下载器下载完 ...
- 关于strtok函数
函数原型: char *strtok(char * strToken, const char *strDelimit) 参数说明: strToken:源字符串,即待分割的串 strDelimit:st ...
- Python+Django+SAE系列教程6-----本地配置Django
前五章.我们介绍了Python的语法,本章開始介绍Django. Python的Web框架有非常多,有Django.web2py.tornado.web.py等.我们这里选 则Django.至于这些框 ...
- MySQL 08章_数据库设计
一. 关系模型与对象模型之间的对应关系 序号 关系模型:数据库 对象模型:java程序 1 数据表table 实体entity:特殊的java类 2 字段field 属性attribute/字段fie ...