题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb某百货公司为了促销,采用购物打折的优惠方法,每位顾客一次购物:在1000元以上者,按9.5折优惠;在2000以上者,按9折优惠;在3000以上者,按8.5折优惠;在5000以上者,按8折优惠;编写程序,购物款数,计算并输出优惠价。
输入描述:
1如题
输出描述:
1如题
输入样例:
1850
21230
35000
43560
输出样例:
1discount=1,pay=850
2discount=0.95,pay=1168.5
3discount=0.8,pay=4000
4discount=0.85,pay=3026
1#include<bits/stdc++.h>
2using namespace std;
3int main(){
4 int price;
5 while(cin>>price){
6 if(price<1000){
7 cout<<"discount=1,pay="<<price;
8 }
9 else if(price<2000){
10 cout<<"discount=0.95,pay="<<price*0.95;
11 }
12 else if(price<3000){
13 cout<<"discount=0.9,pay="<<price*0.9;
14 }
15 else if(price<5000){
16 cout<<"discount=0.85,pay="<<price*0.85;
17 }
18 else{
19 cout<<"discount=0.8,pay="<<price*0.8;
20 }
21 }
22 return 0;
23}
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb输入一个整数n,请你求出1+2+3+4+….+n的和是多少?
输入描述:
1输入一个整数n
输出描述:
1输出1到n的和是多少
2n<=100
输入样例:
15
输出样例:
115
1#include<iostream>
2using namespace std;
3int main(){
4 int n,sum=0;
5 while(cin>>n){
6 sum+=n;
7 while(n--){
8 sum+=n;
9 }
10 cout<<sum;
11 }
12 return 0;
13}
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb求Sn=a+aa+aaa+…+aa…aaa(有n个a)之值,其中a是一个数字。 例如:2+22+222+2222+22222(n=5),
输入描述:
1输入两个数.第一个为a ,第二个为n(表示有多少个数相加),其中a和n都是大于1且小于10的整数.
输出描述:
输出其和.
输入样例:
12 5
输出样例:
124690
1#include<iostream>
2#include<math.h>
3using namespace std;
4int main(){
5 int a,n,sum;
6 while(cin>>a>>n){
7 sum=0;
8 for(int i=0;i<n;i++){
9 sum+=a*pow(10,i)*(n-i);
10 }
11 cout<<sum;
12 }
13 return 0;
14}
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb企业发放的奖金根据利润提成。利润低于或等于100000元的,奖金可提10%;
利润高于100000元,低于200000元(100000<I≤200000)时,低于100000元的部分按10%提成,高于100000元的部分,可提成 7.5%;
200000<I≤400000时,低于200000元部分仍按上述办法提成,(下同),高于200000元的部分按5%提成;
400000<I≤600000元时,高于400000元的部分按3%提成;600000<I≤1000000时,高于600000元的部分按1.5%提成;
I>1000000时,超过1000000元的部分按1%提成。从键盘输入当月利润I,求应发奖金总数。
输入描述:
1一个整数,当月利润。
输出描述:
1一个整数,奖金。
输入样例:
1900
输出样例:
190
1#include<iostream>
2using namespace std;
3int main(){
4 long long profile, adware;
5 while(cin >> profile){
6 if(profile <= 100000){
7 adware = profile * 0.1;
8 }
9 else if(profile <= 200000){
10 adware = 10000 + (profile - 100000) * 0.075;
11 }
12 else if(profile <= 400000){
13 adware = 10000 + 7500 + (profile - 200000) * 0.05;
14 }
15 else if(profile <= 600000){
16 adware = 10000 + 7500 + 10000 +(profile-400000) * 0.03;
17 }
18 else if(profile <= 1000000){
19 adware = 10000 + 7500 + 10000 + 200000 * 0.03 + (profile - 600000) * 0.015;
20 }
21 else{
22 adware = 10000 + 7500 + 10000 + 200000 * 0.03 + 400000 * 0.015 + (profile - 1000000) * 0.01;
23 }
24 cout<<adware;
25 }
26 return 0;
27}
题目描述
Time Limit: 1000 ms
Memory Limit: 256 mb身份证号的校验身份证号码共18位,最后一位是校验位。 A[18] : aaaaaabbbbbbbbccc d
校验的规则如下: 身份证的前十七位数字和对应的权值相乘后相加后所得的和对11取余的余数与校验位(身份证最后一位)相同则身份证合法。
前十七位的权值分别是:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
余数x和校验位y的对应规则对应如下:
x:0 1 2 3 4 5 6 7 8 9 10
y:1 0 x 9 8 7 6 5 4 3 2
输入描述:
1多组数据输入
2输入身份证号码
输出描述:
1如果所输入身份证号码合法,输出ID Corrent,否则输出ID Wrong。
输入样例:
11222222222
211111111111111111111
3341181198809150011
411010119900307387X
5150102199003075131
6150102200003075131
输出样例:
1ID Wrong
2ID Wrong
3ID Corrent
4ID Corrent
5ID Corrent
6ID Wrong
1#include<iostream>
2#include<array>
3using namespace std;
4string id;
5
6array<int,17> wg = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};
7array<char,11> val = {'1','0','X','9','8','7','6','5','4','3','2'};
8
9bool check(string s){
10 if(s.size()!=18){
11 return false;
12 }
13 int weight=0;
14 for(int i=0;i<s.size()-1;i++){
15 weight+=(s[i]-'0')*wg[i];
16 }
17
18 if(val[weight%11]==s[17]){
19 return true;
20 }
21 else{
22 return false;
23 }
24}
25
26int main(){
27 while(cin>>id){
28 if(check(id)){
29 cout<<"ID Corrent"<<endl;
30 }
31 else{
32 cout<<"ID Wrong"<<endl;
33 }
34 }
35}