bnu 被诅咒的代码

http://www.bnuoj.com/bnuoj/problem_show.php?pid=10792

被诅咒的代码

Time Limit:  1000ms
Memory Limit:  65536KB
 
64-bit integer IO format:   %lld       Java class name:   Main
Font Size:   +   -
Type:    None   Graph Theory       2-SAT       Articulation/Bridge/Biconnected Component       Cycles/Topological Sorting/Strongly Connected Component       Shortest Path           Bellman Ford           Dijkstra/Floyd Warshall       Euler Trail/Circuit       Heavy-Light Decomposition       Minimum Spanning Tree       Stable Marriage Problem       Trees       Directed Minimum Spanning Tree       Flow/Matching           Graph Matching               Bipartite Matching               Hopcroft–Karp Bipartite Matching               Weighted Bipartite Matching/Hungarian Algorithm           Flow               Max Flow/Min Cut               Min Cost Max Flow   DFS-like       Backtracking with Pruning/Branch and Bound       Basic Recursion       IDA* Search       Parsing/Grammar       Breadth First Search/Depth First Search       Advanced Search Techniques           Binary Search/Bisection           Ternary Search   Geometry       Basic Geometry       Computational Geometry       Convex Hull       Pick's Theorem   Game Theory       Green Hackenbush/Colon Principle/Fusion Principle       Nim       Sprague-Grundy Number   Matrix       Gaussian Elimination       Matrix Exponentiation   Data Structures       Basic Data Structures       Binary Indexed Tree       Binary Search Tree       Hashing       Orthogonal Range Search       Range Minimum Query/Lowest Common Ancestor       Segment Tree/Interval Tree       Trie Tree       Sorting       Disjoint Set   String       Aho Corasick       Knuth-Morris-Pratt       Suffix Array/Suffix Tree   Math       Basic Math       Big Integer Arithmetic       Number Theory           Chinese Remainder Theorem           Extended Euclid           Inclusion/Exclusion           Modular Arithmetic       Combinatorics           Group Theory/Burnside's lemma           Counting       Probability/Expected Value   Others       Tricky       Hardest       Unusual       Brute Force       Implementation       Constructive Algorithms       Two Pointer       Bitmask       Beginner       Discrete Logarithm/Shank's Baby-step Giant-step Algorithm       Greedy       Divide and Conquer   Dynamic Programming                       Tag it!
程序猿是一种近几十年来出现的新物种,是工业革命的产物。英文(Programmer Monkey)是一种非常特殊的、可以从事程序开发、维护的动物。一般分为程序设计猿和程序编码猿,但两者的界限并不非常清楚,都可以进行开发、维护工作,特别是在中国,而且最重要的一点,二者都是一种非常悲剧的存在。
最新的研究显示,程序猿有一大特点:易猝死。最近经常有某只程序猿猝死的消息直接占满题目作者人人首页的情况出现……
有一天,一只程序猿写了如下一段代码:
然后,突了个然!他就猝死了- -||
现在他剩下的工作被交给了你,请你写一个代码,能输出与这段代码相同的结果。(由于原先的代码遭到了程序猿的诅咒,直接提交他的代码或只是对他的代码进行小的改动是无法通过的……)

Input

第一行为一个整数T(T<=100)表示数据组数,接下来的T行每行一个整数n(n<10 9)。
 

Output

 

对于每组数据,输出一个数表示原先代码输出的结果。

 

 

Sample Input

3
1
2
3
 

Sample Output

1
3
6
 

Source

Author

temperlsyer
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cstring>
 5 using namespace std;
 6 
 7 int a[10]={0,1,3,6,10,15,21,28,36,45};
 8 
 9 int pow_sum2(int a,int n,int m)
10 {
11     int temp=0;
12     a=a%m;
13     while(n)
14     {
15         if(n&1)
16         {
17             temp=temp+a;
18             if(temp>=m)
19             temp=temp-m;
20         }
21         a<<=1;
22         if(a>=m) a=a-m;
23         n>>=1;
24 
25     }
26     return temp;
27 }
28 
29 
30 int main()
31 {
32     int t,n;
33     while(scanf("%d",&t)>0)
34     {
35         while(t--)
36         {
37             scanf("%d",&n);
38             int hxl=n/9;
39             int tom=n%9;
40            // if(tom==0) tom=1;
41             int sum=pow_sum2(45,hxl,10000);
42             sum=(sum+a[tom])%10000;
43             printf("%d\n",sum);
44         }
45     }
46     return 0;
47 }

 

 

转载于:https://www.cnblogs.com/tom987690183/p/3341402.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值