题目描述
这道题有个连除规律,用循环解确实更简洁些,就是输出格式有点复杂,粘贴的时候容易出错
样例
#include<cstdio>
using namespace std;
int main(){
int N;
scanf("%d",&N);
printf("%d\n",N);
printf("%d nota(s) de R$ 100,00\n",N/100);
N=N%100;
printf("%d nota(s) de R$ 50,00\n",N/50);
N=N%50;
printf("%d nota(s) de R$ 20,00\n",N/20);
N=N%20;
printf("%d nota(s) de R$ 10,00\n",N/10);
N=N%10;
printf("%d nota(s) de R$ 5,00\n",N/5);
N=N%5;
printf("%d nota(s) de R$ 2,00\n",N/2);
N=N%2;
printf("%d nota(s) de R$ 1,00\n",N);
return 0;
}
算法1
(暴力枚举) $O(n^2)$
时间复杂度
参考文献
C++ 代码
#include<iostream>
using namespace std;
int main(){
int N;
cin>>N;
cout<<N<<endl;
cout<<N/100<<" "<<nota(s) de R$ 100,00\n<<endl);
N=N%100;
cout<<N/50<<" "<<nota(s) de R$ 50,00\n<<endl;
N=N%50;
cout<<N/20<<" "<<nota(s) de R$ 20,00\n<<endl;;
N=N%20;
cout<<N/10<<" "<<nota(s) de R$ 10,00\n<<endl;
N=N%10;
cout<<N/5<<" "<<nota(s) de R$ 5,00\n<<endl;
N=N%5;
cout<<N/2<<" "<<nota(s) de R$ 2,00\n<<endl;
N=N%2;
cout<<N/1<<" "<<nota(s) de R$ 1,00\n<<endl;
return 0;
}
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla