[JZOJ junior 2042] SuperPow
来源:互联网 发布:淘宝中差评扣分 编辑:程序博客网 时间:2024/06/14 16:42
题目描述
众所周知,a^b表示a的b次幂。例如:2^3=2*2*2=8。
一天,某只肥皂很无聊,于是在纸上写了形如a^b的式子玩。FL见到了,过来一起玩。突然,FL脑洞一开:我给你普及一个符号“^^”,叫做超级幂。a^^b表示a^(a^(a^(a^a^(…)))),共b个a。例如2^^3=2^(2^2)=2^4=16。那么你知道a^^b的个位数是多少么?
肥皂表示一脸懵逼,于是一旁看热闹的YDL出现了,随手写了一个式子:(a1^^b1)(a2^^b2)(a3^^b3)……..(an^^bn),保证ai的个位数不等于2或4或8。说,请求出这个式子的个位数。
肥皂和FL两脸懵逼。现在FL只好想你求助了。
注意:a^^0=1,表示有0个a, 例如: 3^^0=1
Analysis
这题是教练叫我们出题,本蒟蒻出的一道题,竟然用来给小学生考试了。
题目中的肥皂就是lzh,FL就是howarLi,当然YDL就是我。
其实就是一道大水题啦,本人实力有限,只出了这么一题。
题解如下:
我们可以分类讨论(好像也可以找规律)。
对于各组数据之间是独立的,所以我们先只考虑(ai^^bi) mod 10
因为题目只要求输出个位,所以可以让
然后有
若
同理,当
因为题目限制了
当
因为
所以
以
若
否则
当
其实这道题的
Code
#include<cstdio>#include<algorithm>#define fo(i,a,b) for(int i=a;i<=b;i++)using namespace std;const int N=100010;int main(){ freopen("superpow.in","r",stdin); freopen("superpow.out","w",stdout); int T,n,x,y; scanf("%d",&T); while(T--) { int ans=1; scanf("%d",&n); fo(i,1,n) { scanf("%d %d",&x,&y); int z=x%10; if(y==0) continue; if(y==1) { ans=ans*z%10; continue; } if(z==0 || z==1 || z==5 || z==6 || z==9) { ans=ans*z%10; continue; } if(z==3 || z==7) { if(x%4==1) ans=ans*z%10; else ans=ans*(z*z*z%10)%10; continue; } } printf("%d\n",ans); } fclose(stdin);fclose(stdout); return 0;}
- [JZOJ junior 2042] SuperPow
- 【JZOJ junior 2059】 稀有逛超市
- Junior
- awk junior
- junior-week6
- 2042. 【2016.5.21普及组模拟】SuperPow
- vi junior use
- Junior Software QA Engineer
- HTML5移动前端框架:Junior
- Topic of junior development widely debated
- plan for the first term of junior
- Junior high school reading classics test
- NOIP2015 普及组(Junior) 解题报告
- Junior Unity3d Engineer | 初级Unity3d工程师
- [组合] Vijos P1943:[AHOI2015 Junior] 上学路上
- Vina has passed her last junior college course
- [感动]知道我为什么喜欢SUPER JUNIOR吗?
- 手把手教你唱super junior 的《sorry sorry》
- leetcode 24. Swap Nodes in Pairs
- iOS View的Frame和bounds之区别,setbounds使用
- 级联操作
- enjoy java8 section1
- 网络编程的基本概念
- [JZOJ junior 2042] SuperPow
- 寄快递
- JavaScript:事件对象
- 页面评分操作
- 数据库随笔
- android app热更新方案探讨(三)
- [WFD][IOT]通过小米盒子连接电视,概率性卡在接受视频数据界面
- 网页右下角弹出信息框
- LTE基本问题集锦