牛牛学数列
牛牛学数列
https://ac.nowcoder.com/acm/problem/22156
#include<bits/stdc++.h> using namespace std; int main() { int n,i,sum = 0; cin >> n; for(i = 1; i <= n;i++){ sum+= -pow(-1,i)*i; } cout << sum; return 0; }
牛牛学数列
https://ac.nowcoder.com/acm/problem/22156
#include<bits/stdc++.h> using namespace std; int main() { int n,i,sum = 0; cin >> n; for(i = 1; i <= n;i++){ sum+= -pow(-1,i)*i; } cout << sum; return 0; }
相关推荐