HJ82 将真分数分解为埃及分数
题目:https://www.nowcoder.com/practice/e0480b2c6aa24bfba0935ffcca3ccb7b?tpId=37&tqId=21305&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
注意到埃及分数的定义
于是…………我有一个主意◔ ‸◔?
直接把x/y拆分成x个1/y……23333333还真行
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main(){ 4 char c=getchar(); 5 int x=0,y=0; 6 while(c!='/'){ 7 x=x*10+c-'0'; 8 c=getchar(); 9 } 10 c=getchar(); 11 while(c>='0'&&c<='9'){ 12 y=y*10+c-'0'; 13 c=getchar(); 14 } 15 for(int i=1;i<x;i++)cout<<"1/"<<y<<"+"; 16 cout<<"1/"<<y; 17 }
标签:试题库,undefined,while,HJ90,HJ81,getchar From: https://www.cnblogs.com/AlenaNuna/p/18425195