#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
const int u[3] = {1, -3, 2};
const int v[2] = {-2, 3};
int g(int n){
int i, sum = 0;
for (i = 1; i <= n; i++) sum += u[i % 3] * i;
return sum;
}
int main(){
int n, i, sum = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
sum += v[i % 2] * g(i);//103
cout<<"sum="<<sum<<endl;
cout<<"g["<<i<<"]="<<g(i)<<endl;
}
printf("%d\n", sum);
return 0;
}
/*
输入:103
输出:
答案:-400
103
sum=-9
g[1]=-3
sum=-11
g[2]=1
sum=1
g[3]=4
sum=17
g[4]=-8
sum=23
g[5]=2
sum=7
g[6]=8
sum=-32
g[7]=-13
sum=-38
g[8]=3
sum=-2
g[9]=12
sum=34
g[10]=-18
sum=46
g[11]=4
sum=14
g[12]=16
sum=-55
g[13]=-23
sum=-65
g[14]=5
sum=-5
g[15]=20
sum=51
g[16]=-28
sum=69
g[17]=6
sum=21
g[18]=24
sum=-78
g[19]=-33
sum=-92
g[20]=7
sum=-8
g[21]=28
sum=68
g[22]=-38
sum=92
g[23]=8
sum=28
g[24]=32
sum=-101
g[25]=-43
sum=-119
g[26]=9
sum=-11
g[27]=36
sum=85
g[28]=-48
sum=115
g[29]=10
sum=35
g[30]=40
sum=-124
g[31]=-53
sum=-146
g[32]=11
sum=-14
g[33]=44
sum=102
g[34]=-58
sum=138
g[35]=12
sum=42
g[36]=48
sum=-147
g[37]=-63
sum=-173
g[38]=13
sum=-17
g[39]=52
sum=119
g[40]=-68
sum=161
g[41]=14
sum=49
g[42]=56
sum=-170
g[43]=-73
sum=-200
g[44]=15
sum=-20
g[45]=60
sum=136
g[46]=-78
sum=184
g[47]=16
sum=56
g[48]=64
sum=-193
g[49]=-83
sum=-227
g[50]=17
sum=-23
g[51]=68
sum=153
g[52]=-88
sum=207
g[53]=18
sum=63
g[54]=72
sum=-216
g[55]=-93
sum=-254
g[56]=19
sum=-26
g[57]=76
sum=170
g[58]=-98
sum=230
g[59]=20
sum=70
g[60]=80
sum=-239
g[61]=-103
sum=-281
g[62]=21
sum=-29
g[63]=84
sum=187
g[64]=-108
sum=253
g[65]=22
sum=77
g[66]=88
sum=-262
g[67]=-113
sum=-308
g[68]=23
sum=-32
g[69]=92
sum=204
g[70]=-118
sum=276
g[71]=24
sum=84
g[72]=96
sum=-285
g[73]=-123
sum=-335
g[74]=25
sum=-35
g[75]=100
sum=221
g[76]=-128
sum=299
g[77]=26
sum=91
g[78]=104
sum=-308
g[79]=-133
sum=-362
g[80]=27
sum=-38
g[81]=108
sum=238
g[82]=-138
sum=322
g[83]=28
sum=98
g[84]=112
sum=-331
g[85]=-143
sum=-389
g[86]=29
sum=-41
g[87]=116
sum=255
g[88]=-148
sum=345
g[89]=30
sum=105
g[90]=120
sum=-354
g[91]=-153
sum=-416
g[92]=31
sum=-44
g[93]=124
sum=272
g[94]=-158
sum=368
g[95]=32
sum=112
g[96]=128
sum=-377
g[97]=-163
sum=-443
g[98]=33
sum=-47
g[99]=132
sum=289
g[100]=-168
sum=391
g[101]=34
sum=119
g[102]=136
sum=-400
g[103]=-173
-400
--------------------------------
Process exited after 7.117 seconds with return value 0
请按任意键继续. . .
*/
第三章 阅读程序 提高篇 4、【NOIP2001】
https://blog.csdn.net/dllglvzhenfeng/article/details/130917545
NOIP 提高组 初赛 阅读程序写结果
NOIP 提高组 初赛 四、阅读程序写结果 习题集(一)NOIP1998-NOIP1999
NOIP 提高组 初赛 四、阅读程序写结果 习题集(一)NOIP1998-NOIP1999_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(二)NOIP2000-NOIP2001
NOIP 提高组 初赛 四、阅读程序写结果 习题集(二)NOIP2000-NOIP2001_noip2001初赛_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(三)NOIP2002-NOIP2003
NOIP 提高组 初赛 四、阅读程序写结果 习题集(三)NOIP2002-NOIP2003_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(四)NOIP2004-NOIP2005
NOIP 提高组 初赛 四、阅读程序写结果 习题集(四)NOIP2004-NOIP2005_c++输入zzyzcccbbbaaa_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(五)NOIP2006-NOIP2007
NOIP 提高组 初赛 四、阅读程序写结果 习题集(五)NOIP2006-NOIP2007_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(六)NOIP2008-NOIP2009
NOIP 提高组 初赛 四、阅读程序写结果 习题集(六)NOIP2008-NOIP2009_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(七)NOIP2010-NOIP2011
NOIP 提高组 初赛 四、阅读程序写结果 习题集(七)NOIP2010-NOIP2011_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(八)NOIP2012-NOIP2013
NOIP 提高组 初赛 四、阅读程序写结果 习题集(八)NOIP2012-NOIP2013_mrcrack的博客-CSDN博客
NOIP 提高组 初赛 四、阅读程序写结果 习题集(九)NOIP2014-NOIP2015
NOIP 提高组 初赛 四、阅读程序写结果 习题集(九)NOIP2014-NOIP2015_mrcrack的博客-CSDN博客
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题_noip初赛 阅读程序写结果c++_qq_41291769的博客-CSDN博客
【初赛】「阅读程序」题答v1.0
【用脚趾头解决NOIP】(2)NOIP2009~NOIP2015年普及组完善程序
【用脚趾头解决NOIP】(2)NOIP2009~NOIP2015年普及组完善程序_noip 完善程序_xiaoyao24256的博客-CSDN博客
【用脚趾头解决NOIP】(1):NOIP2010~NOIP2015普及组问题求解
【用脚趾头解决NOIP】(1):NOIP2010~NOIP2015普及组问题求解_xiaoyao24256的博客-CSDN博客
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题
C++信息学奥赛题目归类:初赛普及组阅读程序写结果题_noip初赛 阅读程序写结果c++_qq_41291769的博客-CSDN博客
FBZ串问题 NOIP1998
NOIP2017初赛_提高组_阅读程序写结果3.2
NOIP初赛_阅读与理解程序