HDU - 2114 Calculate S(n)

 1 #include <bits/stdc++.h>
 2 #define _xx ios_base::sync_with_stdio(0);cin.tie(0);
 3 #define INFS 0x3fffffff
 4 #define INFB 0x3fffffffffffffff
 5 #define pf printf
 6 #define sf scanf
 7 #define mem(a, b) memset(a, 0, sizeof a);
 8 using namespace std;
 9 typedef long long ll;
10
11 int main()
12 {_xx
13     ll n;
14     while(cin >> n)
15     {
16         ll ans = n*(n + 1)/2;
17         ans %= 10000;
18         ans = ans*ans%10000;
19         cout << setw(4) << setfill(‘0‘) << ans << endl;
20     }
21     return 0;
22 }

时间: 2024-10-29 07:42:50

HDU - 2114 Calculate S(n)的相关文章

HDU 2114 Calculate S(n)(公式)

Calculate S(n) Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9640    Accepted Submission(s): 3492 Problem Description Calculate S(n). S(n)=13+23 +33 +......+n3 . Input Each line will contain

HDU 2139 Calculate the formula

http://acm.hdu.edu.cn/showproblem.php?pid=2139 Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+ n ^2. Input In each case, there is an odd positive integer n. Output Print the sum. Make sure the sum will not excee

HDU - 3347 Calculate the expression — 模拟 + map存变量

传送门 题意:从输入开始,1.输入样例数:2.然后输入一组样例中的行数n:3.前n-1行为定义变量(之间使用空格隔开),只需要map存进去就可以了(这里有覆盖的情况,故使用mp["s"] = "***"的方法赋值,因为insert的方法如果里面存在的话,插不进入数值):4.然后就是最后一行输入计算式子(之间使用空格隔开). 思路:我使用的字符流的方法分割的的字符串,因为题中说了使用空格隔开的: 变量的储存使用map就可以,在最后一行输入计算式子之后,同样使用字符流分

HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,Java就是打表,都不能AC,因为Java的输入是流,需要的时间比C真的长好多.... Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+ n ^2. Input In each

HDU 1012 u Calculate e【暴力打表,水】

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46844    Accepted Submission(s): 21489 Problem Description A simple mathematical formula for e is where n is allowed to go to infini

hdu 1012:u Calculate e(数学题,水题)

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit

poj 1517 &amp; hdu 1012 u Calculate e(简单阶乘)

POJ链接 :http://poj.org/problem?id=1517 HDU链接:http://acm.hdu.edu.cn/showproblem.php?pid=1012 Description A simple mathematical formula for e is e=Σ0<=i<=n1/i! where n is allowed to go to infinity. This can actually yield very accurate approximations o

HDU 1012 u Calculate e(简单阶乘计算)

传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1012 u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 52607    Accepted Submission(s): 24106 Problem Description A simple mathematical

水题/hdu 1012 u Calculate e

题意 求n=0~9时的sigma(1/n!) 分析 因为刚学c++ 所以对浮点操作还是很不熟练,正好来了这么一道题 Accepted Code 1 /* 2 PROBLEM:hdu 1012 3 AUTHER:Nicole Lam 4 MEMO:水题 5 */ 6 #include<iostream> 7 #include<iomanip> 8 using namespace std; 9 double a[10]; 10 int main() 11 { 12 cout<&l