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

📄 toj_2869.cpp

📁 Tianjin University Online Judge 的80多道题目 .
💻 CPP
字号:
/*2869.   Nuanran's Game Time Limit: 1.0 Seconds   Memory Limit: 65536K    Special JudgeTotal Runs: 314   Accepted Runs: 100Recently, nuanran is bored at the QQ Game-LianLianKan. So he defines a new game himself, namely Nuanran's Game.There are infinite stones. Every time nuanran can do one of the following three operations.1. Get x stones.2. Get y stones.3. Throw z stones.Nuanran wants to know how to get n stones finally. Can you help him?InputThe input consists of several test cases. Each test case consists of four integers x, y, z, n in a single line. (0 ≤ x, y, z, n ≤ 200)The input will terminated by the end of file.OutputFor each input test case, if nuanran can get n stones, output a single line with the times of getting x stones, the times of getting y stones and the times of throwing z stones, separated by spaces. Otherwise output -1 in a single line.Please note your answer must fit into 32 signed bits.Sample Input2 4 3 52 4 2 5Sample Output2 1 1-1Note: Special judge problem, you may get "Wrong Answer" when output in wrong format.Source: TJU Team Selection Contest 3*/#include<cstdio>int main(){  short int  a , b , c , x , y , z , n;  while ( scanf( "%hd%hd%hd%hd" , &x , &y , &z , &n ) != EOF )    {      for ( a = 1; a <= 200; a++ )	{	  for ( b = 1; b <= 200; b++ )	    {	      for ( c = 1; c <= 200; c++ )		{		  if ( a * x + b * y - c * z == n )		    {		      printf( "%hd %hd %hd\n" , a , b , c );		      goto end;		    }		}	    }	}      printf( "-1\n" );    end:;    }  return 0;}		  	

⌨️ 快捷键说明

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