๋ฌธ์ œ

https://www.acmicpc.net/problem/10833

์„ค๋ช…

๊ทธ๋ƒฅ ์‚ฌ๊ณผ๋ฅผ ํ•™์ƒ๋“ค์—๊ฒŒ ๋‚˜๋ˆ ์ฃผ๊ณ  ๋‚จ์€ ์‚ฌ๊ณผ์˜ ์ดํ•ฉ์„ ๊ตฌํ•˜๋Š” ๊ฒƒ ์ด๋ฏ€๋กœ ๊ทธ๋ƒฅ mod(%)๋ฅผ ์ด์šฉํ•ด ๋‚˜๋จธ์ง€๋ฅผ ๊ตฌํ•ด ๋ชจ๋‘ ๋”ํ•ด ์ถœ๋ ฅํ•˜๋„๋ก ํ•˜๋ฉด ๋์ด๋‹ค.

์ฝ”๋“œ

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int t = 0,res=0;
	scanf("%d", &t);
	for (int i = 0; i < t; i++)
	{
		int stu = 0, apple = 0;
		scanf("%d %d", &stu, &apple);
		res += apple % stu;
	}
	printf("%d", res);
	return 0;
}