AcWing 653. 钞票——暴力出奇迹
原题链接
困难
作者:
垫底抽風
,
2022-02-12 20:43:03
,
所有人可见
,
阅读 2766
算法1
参考文献
C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<n<<endl;
cout<<fixed<<setprecision(0)<<n/100<<' '<<"nota(s) de R$ "<<"100,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100/50<<' '<<"nota(s) de R$ "<<"50,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100%50/20<<' '<<"nota(s) de R$ "<<"20,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100%50%20/10<<' '<<"nota(s) de R$ "<<"10,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100%50%20%10/5<<' '<<"nota(s) de R$ "<<"5,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100%50%20%10%5/2<<' '<<"nota(s) de R$ "<<"2,00"<<endl;
cout<<fixed<<setprecision(0)<<n%100%50%20%10%5%2<<' '<<"nota(s) de R$ "<<"1,00"<<endl;
}
小菜鸡看不懂嘤嘤嘤
#include [HTML_REMOVED]
using namespace std;
int main(){
int n;
cin>>n;
int a=n/100;
int b=n%100/50;
int c=n%100%50/20;
int d=n%100%50%20/10;
int e=n%100%50%20%10/5;
int f=n%100%50%20%10%5/2;
int g=n%100%50%20%10%5%2/1;
cout<<n<<”\n”<<a<<” nota(s) de R$ 100,00\n”<<b<<” nota(s) de R$ 50,00\n”<<c<<” nota(s) de R$ 20,00\n”<<d<<” nota(s) de R$ 10,00\n”<<e<<” nota(s) de R$ 5,00\n”<<f<<” nota(s) de R$ 2,00\n”<<g<<” nota(s) de R$ 1,00\n”;
// cout<<a<<b<<c;
return 0;
}
#include [HTML_REMOVED]
#include [HTML_REMOVED]
using namespace std;
int main()
{
int a, b,c,d,e,f,g,h,m,p,l,n,u,y;
cin >> a ;
b = a/100;
m = a%100;
c = m/50;
p = m%50;
l = p%20;
d = p/20;
n = l%10;
e = l/10;
u = n%5;
g = n/5;
h = u/2;
y = u%2;
}
juan wang lv zhao yang
好,我给各位献丑了!
#include[HTML_REMOVED]
using namespace std;
int main()
{
int m, i, a, b, c, d, e, f, g;
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
f = 0;
g = 0;
cin >> m;
cout << m << endl;
for(i = 0 ; i <= 10000 ;i){
if(m >= 100){
a;
m = m - 100;
}else if(m >= 50){
b;
m = m - 50;
}else if(m >= 20){
c;
m = m - 20;
}else if(m >= 10){
d;
m = m - 10;
}else if(m >= 5){
e;
m = m - 5;
}else if(m >= 2){
f;
m = m - 2;
}else if(m >= 1){
g;
m = m - 1;
}
}
printf(“%d nota(s) de R$ 100,00\n%d nota(s) de R$ 50,00\n%d nota(s) de R$ 20,00\n%d nota(s) de R$ 10,00\n%d nota(s) de R$ 5,00\n%d nota(s) de R$ 2,00\n%d nota(s) de R$ 1,00\n”, a, b, c, d, e, f, g);
return 0;
}
我这个更暴力
#include [HTML_REMOVED]
#include [HTML_REMOVED]
using namespace std;
int main()
{
int n,a,b,c,d,e,f,g,j;
cin >>j;
n=j;
a=n/100;
n=n%100;
b=n/50;
n=n%50;
c=n/20;
n=n%20;
d=n/10;
n=n%10;
e=n/5;
n=n%5;
f=n/2;
n=n%2;
g=n/1;
n=n%1;
cout << j <<endl;
cout << a <<” nota(s) de R$ 100,00” << endl; cout << b <<” nota(s) de R$ 50,00”<< endl;
cout << c <<” nota(s) de R$ 20,00”<< endl; cout << d <<” nota(s) de R$ 10,00”<< endl;
cout << e <<” nota(s) de R$ 5,00”<< endl; cout << f <<” nota(s) de R$ 2,00”<< endl;
cout << g <<” nota(s) de R$ 1,00”<< endl;
}