首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
小雨910
2025年7月1日 17:34
计算Sn 题解:
P1043
回复 0
|
赞 0
|
浏览 9
Sn=2+22+222+2222+2222 =>Sn=2+[20+2]+[220+2]+[2220+2]+[22220+2] =>Sn=a+前一项*10+a 这里共有五个数,除了第一项,所以循环四次,但是我们发现,第一项也可以用这个规律表示,只是前一项是0 每次循环时要记录前一项的值,这里用temp记录,temp的初始值设置0,关键部分代码可以用三行这么表示: for(i=0;i<n;i++){ temp=0; temp=temp*10+a s...
阿灿
2025年3月18日 16:31
计算Sn 题解:
P1043
回复 0
|
赞 8
|
浏览 1.0k
#include<bits/stdc++.h> using namespace std; int main(){ long long a,n,ans; long long t; while(cin>>a>>n){ ans=0; t = a; for(int i=1;i<=n;i++){ ans += a; a = a*10 + t; } cout<<ans<<endl; } return 0; }
Elysiaaaaaaa
2025年3月8日 12:13
计算Sn 题解:
P1043
回复 0
|
赞 11
|
浏览 549
#include<bits/stdc++.h> using namespace std; int main(){ int a,n; cin>>a>>n; int sum = 0,cnt = 0; ...
jisuanji111
2025年2月18日 17:45
计算Sn 题解:
P1043
回复 0
|
赞 23
|
浏览 906
着重注意2222的构造,不要混淆为a += a*10; #include <bits/stdc++.h> using namespace std; int main() { int a, n; cin >>a >>n; long long a_sum = a; for (int i=1; i<n; i++){ &n...
MEGURI
2025年1月4日 14:26
计算Sn 题解:
P1043
回复 0
|
赞 54
|
浏览 1.3k
#include <stdio.h> int main() { int a, j; scanf("%d %d", &a, &j); long n = 0; long c = a; // 用于存储当前项的值 for (int i = 0; i < j; i++) { &n...
xidianshangan
2025年1月1日 15:43
计算Sn 题解:
P1043
回复 0
|
赞 4
|
浏览 1.4k
#include<iostream> #include<cmath> using namespace std; int main(){ int n,a; long cnt = 0; cin >> a >> n; for(int i = 0;i<n;i++){ cnt = cnt + a*po...
18919717626
2024年6月29日 18:23
计算Sn 题解:
P1043
回复 0
|
赞 9
|
浏览 1.3k
#include <iostream> using namespace std; typedef long long LL; int main(){ int x,n; cin >> x >> n; LL ans = 0,t = 0; for(int i = 1;i <= n;i ++){ t = t * 10 + x; ans = ans + t; } cout << ans << endl; return 0; } &n...
Candour
2024年4月20日 23:58
计算Sn (模拟,注意数据范围)题解:
P1043
回复 0
|
赞 6
|
浏览 1.0k
#include<bits/stdc++.h> using namespace std; typedef long long LL; int x, n; LL ans; int main() { cin >> x >> n; LL t = 0; for(int i = 1; i <= n; i ++) { t = (t * 10 + x); ans += t; } cout << ans; return 0; }
likejjj
2024年3月21日 15:40
计算Sn 题解:
P1043
回复 0
|
赞 0
|
浏览 875
#include<bits/stdc++.h> using namespace std; int main() { int n,m; cin >> n >> m; int tmp = n; int ans = 0; while(m--) { ...
lingdongyang
2024年3月14日 16:19
计算Sn 题解:
P1043
回复 0
|
赞 14
|
浏览 1.4k
#include<stdio.h> int main() { int a, n; scanf("%d %d", &a, &n); int sum = 0; int t = a;//注意找规律a aa aaa 为a*10 再加上他本来的数而不是a变后的值 for (int i = 0; i < n; i++) { sum = sum + a; a = a * 10 + t; } printf("%d",sum); return 0; }
1
2
3
题目
计算Sn
题解数量
23
发布题解
在线答疑
热门题解
1
计算Sn 题解:
2
计算Sn 题解:
3
计算Sn 题解:
4
计算Sn 题解:
5
计算Sn 题解:
6
计算Sn 题解:
7
S=a+aa+aaa+aaaa+......
8
计算Sn (模拟,注意数据范围)题解:
9
计算Sn 题解:
10
计算Sn 题解: