A1037】的更多相关文章

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers some bonus…
给两个序列,一一对应相乘,求最大和. 0不算数,输入时按正负共分为4个数组. #include<cstdio> #include<algorithm> #include<iostream> using namespace std; ; int coupon1[maxn],coupon2[maxn]; int product1[maxn],product2[maxn]; bool cmp(int a,int b){ return a>b; } int main(){…
一.技术总结 这也是一个贪心算法问题,主要在于想清楚,怎么解决输出和最大,两个数组得确保符号相同位相乘,并且绝对值尽可能大. 可以用两个vector容器存储,然后排序从小到大或是从大到小都可以,一次从两端开始相乘,保证符号相同. 二.参考代码 #include<iostream> #include<algorithm> #include<vector> using namespace std; bool cmp(int a, int b){ return a >…
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop also offers some bonus…
1037 Magic Coupon (25 分) The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the sh…
1.B1023 #include<cstdio> int a[10]; int main() { for(int i=0;i<=9;i++) { scanf("%d",&a[i]); } for(int i=1;i<=9;i++) { if(a[i]) { printf("%d",i); a[i]--; break; } } for(int i=0;i<=9;i++) { while(a[i]--) { printf("…
Source: PAT A1037 Magic Coupon (25 分) Description: The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product…
专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d",&a,&b); sum=a+b; ) { printf ("-"); sum=-sum; } ; ) { s[top++]=; } ) { s[top++]=sum%; sum/=; } ;i>=;i--) { printf ("%d"…