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. var 更明确地表示一个变量被设置为零值

    创建一个变量并被初始化其为零值,习惯使用关键字var.这种做法是为了更明确地表示一个变量被设置为零值. 如果变量被初始化为某个非零值,就配合结构字面量和短变量操作符来创建变量. 零值 数值类型:0 字 ...

  2. hashCode和identityHashCode的区别你知道吗?

    hashCode 关于hashCode参考之前的文章,点击参考之前文章. identityHashCode identityHashCode是System里面提供的本地方法,java.lang.Sys ...

  3. wish - 简单的窗口式(windowing) shell

    总览 wish [filename] [arg] [arg ...] 选项 -colormap new 指定窗口使用一个新的私有的调色板(colormap)而不使用给屏幕的缺省的调色板. -displ ...

  4. launch-s.sh 发布脚本备份

    [root@izm5ef2ow9zssfxi6opoucz code]# cat launch-s.sh serverId=1313 zipName=$1 serverPath='code-s'$se ...

  5. boost相关函数

    1.boost::scoped_ptr是一个比较简单的智能指针,它能保证在离开作用域之后它所管理对象能被自动释放 #include <iostream> #include <boos ...

  6. fso文件夹操作用法实操

    Sub 订单转换()Application.ScreenUpdating = FalseOn Error Resume Next Dim fso, fl, m%, n%, p%, q& Dim ...

  7. 【bug】vue同一组件使用

    vue使用同一个组件渲染,进行切换过程中会存在数据保存的情况. 比如路由切换,进行渲染的页面来自同一个组件,这个时候,要在监听路由的时候,将数据重新初始化

  8. [转]Nginx配置详解

    Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作为HTTP服务器,也可作为 ...

  9. 树的直径+质因子——好题!cf1101D

    /* 因为质因子很少 状态转移时用dp[u][i]表示结点u的第i个质因子所在的最大深度即可 等价于带限制的求直径 */ #include<bits/stdc++.h> #include& ...

  10. C++——友元函数和友元类

    友元函数:让函数可以访问类的私有属性 #include <iostream> using namespace std; class A { public: friend class B;/ ...