题目说明;
题目解读:
(读懂题目很重要,题目懂了,算法逻辑都很简单了)
输入格式:
1、给出房子坐标(只有在这个范围内才算落在房子上,才能得分)
2、给出apple和orange的坐标(起始位置)
3、给出apple和orange数目
4、给出apple的每次投掷距离
5、给出orange的每次投掷距离
示例代码:
// apple_orange.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
//by zhaocl
int main()
{
int score_larry = 0;
int score_rob = 0;
int house_a, house_b;
cin >> house_a >> house_b;
int apple_distance, orange_distance;
cin >> apple_distance >> orange_distance;
int apple_num, orange_num;
cin >> apple_num >> orange_num;
int apple_point, orange_point;
while( apple_num-- )
{
cin >> apple_point;
apple_point += apple_distance;
if( apple_point >= house_a && apple_point <= house_b )
score_larry++;
}
while( orange_num-- )
{
cin >> orange_point;
orange_point += orange_distance;
if( orange_point >= house_a && orange_point <= house_b )
score_rob++;
}
cout << score_larry << endl << score_rob << endl;
system( "pause" );
return 0;
}