mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-08 02:13:51 +08:00
Update: Rename folder name to XSMOJ
This commit is contained in:
26
XSMOJ/「例题1-4」鸡兔同笼.cpp
Normal file
26
XSMOJ/「例题1-4」鸡兔同笼.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
int main(){
|
||||
int a,b;
|
||||
cin >>a>>b;
|
||||
long long flag=0;
|
||||
for(int i=0;i<=a;i++){
|
||||
for(int j=0;j<=a;j++){
|
||||
if(i*2+j*4==b && i+j==a){
|
||||
cout <<i<<" "<<j;
|
||||
}
|
||||
else{
|
||||
flag++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(flag==(a+1)*(a+1)){
|
||||
cout <<"No answer";
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user