East BoyleojSome of the answers, the editorial is updated once a week! (Copy the answers consciously quit!)
1015:Getting Started] The Chicken and Rabbit Problem
Title Description
lit. chicken and rabbit in the same cageProblem: A cage contains a number of chickens and a number of rabbits. There are 50 heads and 160 legs. How many chickens and rabbits are there in each cage?
exports
Two integers on one line.
Number of chickens Number of rabbits separated by spaces!
Sample Input
not have
Sample Output
One line, one integer.
-
#include<iostream>
-
using namespace std;
-
int main(){
-
for(int i=1;i<=80;i++){
-
for(int j=1;j<=40;j++){
-
if(i+j==50&&i*2+j*4==160){
-
cout<<i<<" "<<j;
-
}
-
}
-
}
-
return 0;
-
}
1016:[Getting Started] Buying Kittens and Puppies
Title Description
An animal breeding center earmarks $X to purchase two small animals, puppies ($A each) and kittens ($B each).
Request earmarks, (at least one each for cats and dogs), just in time to use them up? Request the total number of programs. If not, please output 0.
importation
Enter a line with only three integers. X,A,B. ( 100 < X < 32768; 1 <= A, B <= 100 )
exports
The output is only one line (which means there is a carriage return symbol at the end) and consists of 1 integer.
Sample Input
1700 31 21
Sample Output
3
-
#include<iostream>
-
using namespace std;
-
int main(){
-
int x,a,b,cnt=0;
-
cin>>x>>a>>b;
-
for(int i=1;i<x/a;i++){
-
for(int j=1;j<x/b;j++){
-
if((i*a+j*b)==x){
-
cnt++;
-
}
-
}
-
}
-
cout<<cnt;
-
return 0;
-
}
1017:Getting Started] Finding the number of parts
Title Description
There is a pile of more than 100 parts; if you count three by three, there are two left; if you count five by five, there are three left; if you count seven by seven, there are five left. Can you write a program to calculate at least how many parts are in the pile?
importation
not have
exports
One line, one integer.
-
#include <iostream>
-
using namespace std;
-
int main(){
-
for(int i=101;i<200;i++){
-
if(i%3==2&&i%5==3&&i%7==5){
-
cout<<i<<endl;
-
break;
-
}
-
}
-
return 0;
-
}
1020:[Getting Started] What is the sum of
Title Description
Input a three-digit positive integer and add it to its inverse to output the sum.
E.g. if you enter 167, the sum is 167+761=928
importation
Only one line, a three-digit positive integer.
exports
A positive integer
Sample Input
167
Sample Output
928
-
#include<iostream>
-
using namespace std;
-
int main(){
-
int a;
-
cin>>a;
-
cout<<a+a%10*100+(a/10)%10*10+a/100;
-
return 0;
-
}
1021:Beginner's Guide] Finding Numbers II
Title Description
Find all integers in the range 1-500 that satisfy both division by 3 with remainder 2, division by 5 with remainder 3, and division by 7 with remainder 2.
importation
not have
exports
several
One per line
-
#include<iostream>
-
using namespace std;
-
int main(){
-
for(int i=1;i<=500;i++){
-
if(i%3==2&&i%5==3&&i%7==2){
-
cout<<i<<" "<<endl;
-
}
-
}
-
return 0;
-
}
1022:[Getting Started] The Hundred Cents and Hundred Chickens Problem
Title Description
Buy 100 chickens, roosters, hens, and chicks for $100. The rooster costs 5 dollars a piece, the hen 3 dollars a piece, and the chicks 1 dollar 3 pieces. How many roosters, hens, and chicks should you buy?
importation
not have
exports
Each buy takes up one row and consists of 3 numbers in the order of the number of roosters, the number of hens, and the number of chicks. Each number is separated by a space.
-
#include<iostream>
-
using namespace std;
-
int main(){
-
for(int i=1;i<=20;i++){
-
for(int j=1;j<=33;j++){
-
for(int k=1;k<=100;k++){
-
if(i+j+k==100&&i*5+j*3+k/3.0==100){
-
cout<<i<<" "<<j<<" "<<k<<endl;
-
}
-
}
-
}
-
}
-
return 0;
-
}
1025:[Getting Started] Coin Exchange
Title Description
A dollar bill is exchanged for 1, 2, and 5 cent coins, at least one of each, Q. How many ways are there to exchange them?
importation
not have
exports
The output is only one line (which means there is a carriage return symbol at the end) and consists of 1 integer.
-
#include<iostream>
-
using namespace std;
-
int main(){
-
int sum=0;
-
for(int i=1;i<=100;i++){
-
for(int j=1;j<=50;j++){
-
for(int k=1;k<=20;k++){
-
if(i+j*2+k*5==100){
-
sum++;
-
}
-
}
-
}
-
}
-
cout<<sum;
-
return 0;
-
}
1027:Getting Started] Finding the sum of the digits of any three-digit number.
Title Description
For an arbitrary three-digit natural number X, program the sum S of the digits in each of its digits.
importation
Enter a line with only one integer x (100<=x<=999)
exports
The output is only one line and consists of 1 integer
Sample Input
123
Sample Output
6
-
#include<iostream>
-
using namespace std;
-
int main(){
-
int x;
-
cin>>x;
-
cout<<x/100+x/10%10+x%100%10;
-
return 0;
-
}
1028:[Getting Started] Input a three-digit number and output it after matching the first and second digits.
Title Description
Input a three-digit natural number, then swap the hundredths digit of this number with the first digit, and output the swapped number
If a leading 0 exists after flip-flop, output leading 0 normally, e.g., 130, should output 031
importation
Enter a line with only one integer x (100<=x<=999).
exports
The output is only one line and consists of 1 integer.
Sample Input
123
Sample Output
321
-
#include<iostream>
-
using namespace std;
-
int main(){
-
int x,a,b,c;
-
cin>>x;
-
a=x/100;
-
b=x%100%10;
-
c=x%100/10;
-
cout<<b<<c<<a;
-
return 0;
-
}