题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1295

1295. Crazy Notions

Time limit: 0.5 second
Memory limit: 64 MB
For five days robot-loader JK546L54p has been buried under the thick layer of the Sibelian plutonium slag. The terrible strike of the atmospheric electricity has led to the depressurization of the robot’s fuel elements. Who will examine this heap of fused, broken metal here, where there is no any robot technician even at distance of a hundred parsecs? Robot-commissar even did not try to investigate what happened with JK546L54p. He ordered to throw him out into dumps and that is all. Nobody noticed that positron brains of JK546L54p were still working. If only the robopsychologist was here with JK546L54p! Of course, he would be killed with the hard gamma radiation in a moment, but… If he attached the visualizer of thoughts to the fused connectors of JK546L54p! He would see the strange performance. Robot was creating! No, I am not joking. He was investigating. Semi casual objects arose in his mind, and he examined them. Crazy properties, crazy theorems.
Besides, here is an example. Let’s take an expression 1 n+2 n+3 n+4 n. How much zeros does its decimal notation end with? JK546L54p solved this problem, and you, student, could you?

Input

The only line contains an integer  n (1 ≤  n ≤ 300000).

Output

Output the number of zeroes the decimal notation of 1 n+2 n+3 n+4 n ends with.

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(数学 规律)相关推荐

  1. 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 ...

  2. 1295. Crazy Notions

    原文: http://acm.timus.ru/problem.aspx?space=1&num=1295 针对输入的整数n, 计算 1**n + 2**n + 3**n + 4**n  以0 ...

  3. 【算法学习笔记】73.数学规律题 SJTU OJ 1058 小M的机器人

    Description 小M有很多个机器人,他们要么一直说真话,要么一直说假话. 然后每个人都说: (1). 不到N个人比我工作得多 (2). 至少M个人的工资比我高. 保证没有两个人的工作一样重,也 ...

  4. 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 ...

  5. UVA10162 Last Digit【数学规律】

    Give you a integer number N (1 ≤ n ≤ 2 ∗ 10100). Please compute S = 11 + 22 + 33 + . . . + NN Give t ...

  6. UVA10025 The ? 1 ? 2 ? ... ? n = k problem【数学规律】

    Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtai ...

  7. 用Python解中考数学规律题

    用Python解中考数学规律题 以下为2018成都市的中考数学真题B卷第23题: 分析:   一.这是一道常规的找规律考题,一般每年的中考数学都会涉及,根据题的难易程度,位置一般会出现在B卷的第二题, ...

  8. 1235813找规律第100个数_2018年中考数学规律探索题(中考找规律题目-有答案)

    <2018年中考数学规律探索题(中考找规律题目-有答案)>由会员分享,可在线阅读,更多相关<2018年中考数学规律探索题(中考找规律题目-有答案)(16页珍藏版)>请在金锄头文 ...

  9. GCD XOR UVA - 12716 ——筛法建立约数表+xor运算+数学规律

    Think: 1埃式筛法思想建立约数表 2初始打表寻找运算的数学规律 3xor运算(不带进位的二进制加法) 运算法则 1. a ⊕ a = 0 2. a ⊕ b = b ⊕ a 3. a ⊕b ⊕ c ...

最新文章

  1. JPEG图片扩展信息读取与改动
  2. mysql客户端工具的使用
  3. 完美解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget
  4. 脚本命令配置mysql_MySQL常用的配置、脚本和命令
  5. 自然语言处理系列-1.什么是NLP?
  6. HIve之DML 聚合分组应用函数 静动态分区表
  7. 如何下载指定版本的elasticsearch和kibana
  8. 巴西发生矿坝决堤事故 外媒:90名受困者已救出
  9. MP4Box切割mp4视频文件
  10. 如何将flac音频格式转换mp3格式呢
  11. 图像处理:图像清晰度评价
  12. Java基础之网络编程
  13. 速来!0元优质低代码平台抢先体验
  14. 好用的办公邮箱是提高工作效率的第一步
  15. labview文件上传服务器,基于labview的局域网TCP传输文件夹问题的解决
  16. 【Unity3D】地形和天空盒子
  17. java求圆锥的体积并比较大小_帮写下作业,Java代码编写程序,声明变量保存圆锥的底圆半径和高,计算圆锥的体积和底圆面积,final double P...
  18. 如何做好英文外贸B2C网站的优化
  19. 关于 Ant Design 的一些笔记
  20. 计算机网络经典选择题20道

热门文章

  1. [机缘参悟-54]:《素书》-1-事物缘起[原始章第一]:大道至简。
  2. python零基础入门书籍-零基础python入门书籍推荐读哪些书?
  3. Linux--查看常驻进程:ps
  4. 基于Java的学生综合素质评估系统的设计与实现
  5. CIC梳妆滤波器matlab仿真
  6. 不懂建站技术如何快速搭建一个网站
  7. 海尔T520智能扫地机器人使用评测
  8. Codeforces Round #105 D. Bag of mice 概率dp
  9. 深度学习笔记(4)——维度操作(2)展平、·拼接、拆分
  10. MeshCollider渲染面片