백준 알고리즘(C/C++) - 10430번 나머지

#include <stdio.h>

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	printf("%d\n", (a+b)%c);
	printf("%d\n", ((a%c)+(b%c))%c);
	printf("%d\n", (a*b)%c);
	printf("%d\n", ((a%c)*(b%c))%c);
	return 0;
}
#include <iostream>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << (a+b)%c << std::endl;
	std::cout << ((a%c)+(b%c))%c << std::endl;
	std::cout << (a*b)%c << std::endl;
	std::cout << ((a%c)*(b%c))%c << std::endl;
	return 0;
}

댓글

Designed by JB FACTORY