⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 9.txt

📁 7道ACM题
💻 TXT
字号:
#include <stdio.h>


int main()
{
	int a, b, c, d;
	scanf( "%d%d%d%d", &a, &b, &c, &d );

	int time = 1;
	while ( a != -1 )
	{
		int sum = 0;
		int limit = 21252;
		int a1 = a % 23, b1 = b % 28, c1 = c % 33;

		/*if ( a1 == b1 && b1 == c1 )
		{
			if ( a1 > d )
				printf( "Case %d: the next triple peak occurs in %d days.\n", time++, a1 - d );
			else
				if ( a1 == d )
					printf( "Case %d: the next triple peak occurs in %d days.\n", time++, 21252 );
				else
					printf( "Case %d: the next triple peak occurs in %d days.\n", time++, 21252 - d );
		}
		else if ( a == b && b == c )
		{
			if ( a > d )
				printf( "Case %d: the next triple peak occurs in %d days.\n", time++, a - d );
			else
				printf( "Case %d: the next triple peak occurs in %d days.\n", time++, 21252 - d );
		}
		else
		{*/

		for ( int i = 0; i < limit / 23; i++ )
		{
			int a2 = i * 23;
			for ( int j = 0; j <= i; j++ )
			{
				int b2 = j * 28;
				if ( a2 + a1 == b2 + b1 )
				{
					for ( int k = 0; k <= j; k++ )
					{
						int c2 = k * 33;
						if ( b2 + b1 == c2+ c1 )
						{
							sum = a2 + a1;
							goto over;
						}
					}
				}
			}
		}
		over:
		if ( sum == d )
			sum = 21252;
		else if ( sum < d )
			sum = 21252 - ( d - sum );
		else
			sum -= d;
	
		printf( "Case %d: the next triple peak occurs in %d days.\n", time++, sum );
		

		scanf( "%d%d%d%d", &a, &b, &c, &d );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -