#include <stdio.h>
#define N 3000
int main()
{
int time[N];//在学校上课的时间
int time1[N];//补课的时间
int unhappy = 0;//今天不高兴的值
int unhappys = 0;//不高兴程度的和
int i;
int n;
//录入每天学习的时间
scanf("%d",&n);
for(i = 0;i < n;i ++)
{
scanf("%d %d",&time[i],&time1[i]);
}
//累加不高兴的程度
for(i = 0;i < n;i ++)
{
unhappy = unhappy + time[i] + time1[i] - 8;
unhappys += unhappy;
}
printf("%d",unhappys);
}
//方法2
#include <stdio.h>
int main()
{
int unhappy = 0;//当天不高兴的程度
int unhappys = 0;//不高兴程度的和
int time1;//在学校上课的时间
int time2;//补习的时间
int n;//几天
int i;
scanf("%d",&n);
for(i = 0;i < n;i ++)
{
scanf("%d %d",&time1,&time2);
unhappy = unhappy + time1 + time2 - 8;
unhappys += unhappy;
}
printf("%d",unhappys);
return 0;
}
洛谷P1534
最新推荐文章于 2024-05-05 00:25:23 发布