其他分享
首页 > 其他分享> > CCF-CSP 201709-1 打酱油(C语言)

CCF-CSP 201709-1 打酱油(C语言)

作者:互联网

CCF-CSP 201709-1 打酱油(C语言)

#include <stdio.h>

int main(){
	int N,price = 10,sum;
	scanf("%d",&N);
	
	if(N<30){
		sum = N / price;
	}
	else if(N>=30&&N<50){
		sum = 4+(N-30)/price;
	}
	else if(N>=50&&N<80){
		sum = 7+(N-50)/price;
	}
	else if(N>=80&&N<100){
		sum = 7+4+(N-80)/price;
	}
	else if(N>=100&&N<=300){
		int x = N / 50;
		int s = N - 50 * x;
		int y;
		if(s>=30){
			y = s / 30;
		}
		else{
			y=0;
		}
		int s3 = s-30*y;
		
		sum = 7 * x+4*y+s3 / price; 
	} 
	
	printf("%d",sum);
	
	return 0;
}

标签:201709,int,price,30,50,CSP,else,CCF,sum
来源: https://blog.csdn.net/weixin_44828720/article/details/120236747