[HDU] week1.2

杭电链接

1001. Sum Problem

#include <stdio.h>

int main()
{
    
    
    int n,sum;
    while(scanf("%d",&n)!=EOF){
    
    
        sum=n*(n+1)/2.0;
        //sum=n/2.0*(n+1);
        printf("%ld\n\n",sum);
    }

    return 0;
}

1061. Rightmost Digit

#include <stdio.h>

int best[20] = {
    
     0, 1, 4, 7, 6, 5, 6, 3, 6, 9, 
					0, 1, 6, 3, 6, 5, 6, 7, 4, 9 };
int n, t;
int main()
{
    
    
    scanf("%d",&t);
	while (t--) {
    
    
        scanf("%d",&n);
        printf("%d\n",best[n % 20]);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Jingle_dog/article/details/120287677
hdu