URAL 1295. Crazy Notions(数学 规律)
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1295
1295. Crazy Notions
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
1 |
1 |
3 |
2 |
代码如下(找规律):
#include <cstdio>
#define LL __int64
//int main()
//{
// int n;
// for(int i = 1; i <= 32; i++)
// {
// LL ans1 = 1;
// LL ans2 = 1;
// LL ans3 = 1;
// LL ans4 = 1;
// for(int j = 1; j <= i; j++)
// {
// ans2*=2;
// ans3*=3;
// ans4*=4;
// }
// int cnt = 0;
// LL ans = ans1+ans2+ans3+ans4;
// while(ans)
// {
// if(ans%10 == 0)
// {
// cnt++;
// ans/=10;
// }
// else
// {
// break;
// }
// }
// printf("%d:: ans:%d\n",i,cnt);
// }
// return 0;
//}
int main()
{int n;int a[30]= {1,1,2,0,2,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0};while(~scanf("%d",&n)){printf("%d\n",a[(n-1)%20]);}return 0;
// while(~scanf("%d",&n))
// {
// if(n%4 == 0)
// {
// printf("0\n");
// }
// else if((n%4==1 &&n%5==0) || n%4==3)
// {
// printf("2\n");
// }
// else
// {
// printf("1\n");
// }
// }return 0;
}
贴一发别人的:
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
long long mod=100000;
long long quickmulti(long long m,long long n)//二分快速幂
{long long ans=1;long long i;while(n){if(n&1)ans=(m*ans)%mod;m=(m*m)%mod;n>>=1;}return ans;
}int main()
{long long n;while(scanf("%lld",&n)!=EOF){long long ans=1;ans+=quickmulti(2,n);ans%=mod;ans+=quickmulti(3,n);ans%=mod;ans+=quickmulti(4,n);ans%=mod;long long tem=ans;long long tt=0;while(tem%10==0){tem/=10;tt++;}printf("%lld\n",tt);}return 0;
}
URAL 1295. Crazy Notions(数学 规律)相关推荐
- Timus 1295. Crazy Notions
原题:Crazy Notions 题目:读入N,求1^n+2^n+3^n+4^n结尾有多少个0 解法:1.暴力算出来,发现其实0的个数不会超过2 2.找规律,0,1,1,2,0,2,1,2,0,1,1 ...
- 1295. Crazy Notions
原文: http://acm.timus.ru/problem.aspx?space=1&num=1295 针对输入的整数n, 计算 1**n + 2**n + 3**n + 4**n 以0 ...
- 【算法学习笔记】73.数学规律题 SJTU OJ 1058 小M的机器人
Description 小M有很多个机器人,他们要么一直说真话,要么一直说假话. 然后每个人都说: (1). 不到N个人比我工作得多 (2). 至少M个人的工资比我高. 保证没有两个人的工作一样重,也 ...
- UVA11774 Doom‘s Day【数学规律+GCD】
We all know about the legend of tower of Hanoi. It is said that the world will end after finishing t ...
- UVA10162 Last Digit【数学规律】
Give you a integer number N (1 ≤ n ≤ 2 ∗ 10100). Please compute S = 11 + 22 + 33 + . . . + NN Give t ...
- UVA10025 The ? 1 ? 2 ? ... ? n = k problem【数学规律】
Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtai ...
- 用Python解中考数学规律题
用Python解中考数学规律题 以下为2018成都市的中考数学真题B卷第23题: 分析: 一.这是一道常规的找规律考题,一般每年的中考数学都会涉及,根据题的难易程度,位置一般会出现在B卷的第二题, ...
- 1235813找规律第100个数_2018年中考数学规律探索题(中考找规律题目-有答案)
<2018年中考数学规律探索题(中考找规律题目-有答案)>由会员分享,可在线阅读,更多相关<2018年中考数学规律探索题(中考找规律题目-有答案)(16页珍藏版)>请在金锄头文 ...
- GCD XOR UVA - 12716 ——筛法建立约数表+xor运算+数学规律
Think: 1埃式筛法思想建立约数表 2初始打表寻找运算的数学规律 3xor运算(不带进位的二进制加法) 运算法则 1. a ⊕ a = 0 2. a ⊕ b = b ⊕ a 3. a ⊕b ⊕ c ...
最新文章
- JPEG图片扩展信息读取与改动
- mysql客户端工具的使用
- 完美解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- 脚本命令配置mysql_MySQL常用的配置、脚本和命令
- 自然语言处理系列-1.什么是NLP?
- HIve之DML 聚合分组应用函数 静动态分区表
- 如何下载指定版本的elasticsearch和kibana
- 巴西发生矿坝决堤事故 外媒:90名受困者已救出
- MP4Box切割mp4视频文件
- 如何将flac音频格式转换mp3格式呢
- 图像处理:图像清晰度评价
- Java基础之网络编程
- 速来!0元优质低代码平台抢先体验
- 好用的办公邮箱是提高工作效率的第一步
- labview文件上传服务器,基于labview的局域网TCP传输文件夹问题的解决
- 【Unity3D】地形和天空盒子
- java求圆锥的体积并比较大小_帮写下作业,Java代码编写程序,声明变量保存圆锥的底圆半径和高,计算圆锥的体积和底圆面积,final double P...
- 如何做好英文外贸B2C网站的优化
- 关于 Ant Design 的一些笔记
- 计算机网络经典选择题20道