Sum Problem
#include <stdio.h>
int main(void) {
int a;
while (scanf("%d", &a) == 1)
{
if (a % 2 == 0)
printf("%d\n\n", (a / 2) * (a + 1));
else
printf("%d\n\n", ((a + 1) / 2) * a);
}
}
#include <stdio.h>
int main(void) {
int a;
while (scanf("%d", &a) == 1)
{
if (a % 2 == 0)
printf("%d\n\n", (a / 2) * (a + 1));
else
printf("%d\n\n", ((a + 1) / 2) * a);
}
}
本文标题:杭电oj-1001
本文链接:https://www.haomeiwen.com/subject/iwnopctx.html
网友评论