1 条题解
-
0
C++ :
#include <iostream> using namespace std; int main(){ int max = 30 * 1200; int p = 30; int c = 1200; int s;//售价 int n; cin>>n; int price = p;//假设p元最划算 while(c > 0){ p++; c -= n;//每加1元,数量减少n张 s = p * c; // cout<<p<<" "<<c<<" "<<s<<endl; if(s > max){ max = s; price = p; } } cout<<price<<" "<<max<<endl; }
Python :
n = int(input()) x = 30 y = 1200 j = [] m = [] while(x <= y): z = x * y j.append(z) if(max(j) == x * y): m.append(x) x += 1 y -= n print(max(m), max(j))
- 1
信息
- ID
- 2275
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者