3857 - 雉兔同笼
《孙子算经》里有个问题:今有雉兔同笼,上有三十五头,下有九十四足,问雉兔各几何?
让我们来编程解决这个问题吧。
</p>
<p>
<span style="font-size:18px;font-family:SimHei;color:black;"><br />
</p>
Input
输入两个正整数,分别表示头和足的数目。
Output
输出两个正整数,分别表示雉和兔的数目。每个数占一行
Examples
Input
35 94
Output
23 12
Solution C
#include"stdio.h" int main() { int a,b,x,y; scanf("%d%d",&a,&b); y=(b-2*a)/2; x=a-y; printf("%d\n%d",x,y); return 0; }
Solution C++
#include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; int x=2*a-b/2; int y=a-x; cout<<x<<endl; cout<<y; return 0; }