1609: 求和

Time Limit: 1 Sec  Memory Limit:
128 MB

Submit: 209  Solved: 67



SubmitStatusWeb
Board

Description

若S=15+195+1995+19995+···+199···95(n-1个9),则和数S的
末四位数字的和是多少(如果不够四位求各个位上的和)?

Input

多实例测试,每组输入一个正整数n,n不大于1000000.

Output

输出S的末四位数字之和

Sample Input

45

Sample Output

24

HINT

Source

n=1,2,3,的时候算是特殊情况,3之后只需要前三个的和2205和9995相加,但是每一步相加都应该控制在10000以内

#include<stdio.h>
#include<string.h>
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n==1) printf("6\n");
else if(n==2) printf("3\n");
else if(n==3) printf("9\n");
else
{
n-=3;
int sum=2205;
while(n)
{
sum+=9995;
while(sum>10000)
sum-=10000;
n--;
}
while(sum>10000)
sum-=10000;
int s=0;
while(sum)
{
s+=sum%10;
sum/=10;
}
printf("%d\n",s);
}
}
return 0;
}

zzulioj--1609--求和(数学规律)的更多相关文章

  1. Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))

    C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. [wx]自然数学规律

    有趣的数学规律 椭圆 双曲线 抛物线都叫圆锥曲线 它们跟圆锥有着怎样的关系? 他们都是圆锥与平面在不同姿势下交配的产物. 参考 椭圆 抛物线 小结 e: 离线率 P: 任意一点 F: 焦点 准线: 一 ...

  3. PAT甲级——1104 Sum of Number Segments (数学规律、自动转型)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90486252 1104 Sum of Number Segmen ...

  4. hihoCoder 1584 Bounce 【数学规律】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1584 : Bounce 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 For Argo, it is very interesting watching a cir ...

  5. 【数学规律】Vijos P1582 笨笨的L阵游戏

    题目链接: https://vijos.org/p/1582 题目大意: 就是o(o<=50)个人在n*m(n,m<=2000)的格子上放L型的东西(有点像俄罗斯方块的L,可对称旋转),问 ...

  6. 2154 杭电 数学规律 ACM

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2154 很简单的找规律的数学题目: 思路:因为挑完N次后都要跳回A,所以相当于挑N-1次后必须留在B C区域 ...

  7. HDU 4342——History repeat itself——————【数学规律】

    History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

  8. Codeforces 626C Block Towers「贪心」「二分」「数学规律」

    题意: 一堆人用方块盖塔,有n个人每次只能加两块方块,有m个人每次只能加三块方块.要求每个人盖的塔的高度都不一样,保证所用方块数最少,求最高的塔的高度. 0<=n+m  0<=n,m< ...

  9. Codeforces Round #272 (Div. 2) D. Dreamoon and Sets (思维 数学 规律)

    题目链接 题意: 1-m中,四个数凑成一组,满足任意2个数的gcd=k,求一个最小的m使得凑成n组解.并输出 分析: 直接粘一下两个很有意思的分析.. 分析1: 那我们就弄成每组数字都互质,然后全体乘 ...

随机推荐

  1. EntityFramework 找不到方法:“Void System.Data.Entity.DbModelBuilder.RegisterEntityType

    问题原因,EF当前版本没有该方法,将EF版本升级即可. 1.packages.config <package id="EntityFramework" version=&qu ...

  2. 用shell脚本实现linux系统上wifi模式(STA和soft AP)的转换

    转载请注明出处:http://blog.csdn.net/hellomxj1/ 功能:在linux系统上实现wifi STA与AP功能的转换 实现成果:1.加入wifipassword账户add_wi ...

  3. java位运算笔记

    位运算: ~(非)-->二进制数进行0和1的互换 样例: public class Test { public static void main(String[] args) { System. ...

  4. Control-of-Flow

    https://docs.microsoft.com/en-us/sql/t-sql/language-elements/control-of-flow The Transact-SQL contro ...

  5. kentico在使用局域网ip访问的时候提示Missing license或者Invalid website

    Missing license Requested URL: http://172.31.212.20/kentico10/ License status: Missing license If yo ...

  6. 剑指offer——03从尾至头打印列表(Python3)

    思路:相当于数据结构中的链表就地逆置,可以使用头插法来实现. 代码: class Solution:     # 返回从尾部到头部的列表值序列,例如[1,2,3]     def printListF ...

  7. POJ 3660 Floyd传递闭包

    题意:牛有强弱,给出一些牛的强弱的胜负关系,问可以确定几头牛的排名. 思路: Floyd传递闭包 // by SiriusRen #include <bitset> #include &l ...

  8. javascript中常用数组方法详细讲解

    javascript中数组常用方法总结 1.join()方法: Array.join()方法将数组中所以元素都转化为字符串链接在一起,返回最后生成的字符串.也可以指定可选的字符串在生成的字符串中来分隔 ...

  9. log4j:WARN Please initialize the log4j system properly.解决方案

    在使用quarz任务调度框架时的错误,实际上这个问题很常见,并不影响程序的使用,只是缺少日志输出,完整错误信息: log4j:WARN No appenders could be found for ...

  10. SpringMVC(六)POJO类作为 @RequestMapping方法的参数

    Command or form objects to bind request parameters to bean properties (via setters) or directly to f ...