QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#510604#7658. German Conference for Public CountingMinyou0713WA 0ms3704kbC++144.0kb2024-08-09 09:38:092024-08-09 09:38:09

Judging History

你现在查看的是最新测评结果

  • [2024-08-09 09:38:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-08-09 09:38:09]
  • 提交

answer

//2024 夏季训练赛 L
//E题 学习思路,优化思维,调整代码习惯


// #include<iostream>
// #include<cstring>
// using namespace std;

// int main(){
//    string s;
//    cin>>s;
//    int count = 0;
//    for(int i=0;i<s.size();i++){
//       s[i]=s[i]+('a'-'A');
//       if(s[i]=='s'&&s[i-1]=='s'){
//          count++;
//       }
//    }
//    count=count+1;
//    if(count<2) {
//       for(int i=0;i<s.size();i++){
//          cout<<s[i];
//       }
//    }
//    else {
//       for(int i=0;i<s.size();i++){
//          cout<<s[i];
//       }
//       cout<<endl;
//       int m = count - 1;
//       for(int i=0;i<m;i++){
//          int u = 0;
//          for(int j=0;j<s.size();j++){
//             if(s[j]=='s'){
//                u++;
//                if(s[j-1]!='s'&&s[j+1]!='s'&&j+1<s.size()) 
//                {  
//                   if(j==0){
//                      if(s[j+1]!='s'&&j+1<s.size()) u--;
//                   }
//                   else 
//                   u--;
//                }
//                if(u==i+1){
//                   cout<<"B";
//                   j++;
//                }
//                else{
//                   cout<<s[j];
//                }
//             }
//             else {
//                cout<<s[j];
//             }
//          }
//          cout<<endl;
//       }
//    }
//    return 0;
// }

// #include <bits\stdc++.h>
// #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
// #define endl '\n'
// #define PII pair<int, int>
// using namespace std;

// void solve(){
//    string s;
//    cin>>s;
//    for(int i=0;i<s.size();i++){
//       s[i]=s[i]+32;
//    }
//    cout<<s;
//    cout<<endl;
//    for(int i=0;i<s.size();i++){
//       if(s[i]=='s'&&s[i+1]=='s'){
//          for(int j=0;j<i;j++) cout<<s[j];
//          cout<<'B';
//          for(int j=i+2;j<s.size();j++) cout<<s[j];
//          cout<<endl;
//       }
//    }

// }

// signed main(){
//    IOS;
//    int tt;
//    tt=1;
//    //cin>>tt;
//    while(tt--)
//       solve();
//    return 0;
// }

//D题
// #include <bits\stdc++.h>
// using namespace std;
// #define endl '\n'
// #define int long long 
// #define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
// typedef unsigned long long ull ;
// typedef long long ll ;
// typedef pair<int, int>PII;

// int a,b,c,d,e;

// void solve(){
//    cin>>a>>b>>c>>d>>e;
//    int mn = a+b+c+d+e;
//    int mx = a*4+b*6+c*8+12*d+20*e;
//    vector<int>ans;
//    while(mn<=mx){
//       ans.push_back(mx);
//       if(mn!=mx) ans.push_back(mn);    //方法:奇偶区分可合并
//       mx--;mn++;
//    }
//    reverse(ans.begin(),ans.end());
//    for(int i=0;i<ans.size();i++){
//       cout<<ans[i]<<' ';
//    }
// }

// signed main(){
//    IOS;
//    int tt;
//    tt=1;
//    //cin>>tt;
//    while(tt--)
//       solve();
//    return 0;
// }

//G题
//类似的数学题目,关键在于找公式和找规律,往往代码很巧妙
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
#define endl '\n'
#define int long long 
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef unsigned long long ull ;
typedef long long ll ;
typedef pair<int, int>PII;

void solve(){
   int n;
   cin>>n;
   if(n<10) {
      cout<<n+1;
      return ;
   }
   if(n==10){
      cout<<10;
      return ;
   }

//计算位数算法需优化
   int x = n;
   int a = 1, b = 1;
   int t = 1;
   while(x/10){
      a=x/10;
      t++;
      if(x/100==0&&x/10!=0){
         b=x%10;
      }
      x/=10;
   }

   int ans;
   // if(a<=b) ans = a*t+(10-a)*(t-1);
   // else ans = (a-1)*t+(11-a)*(t-1);
   if(a<=b) ans = 10*(t-1)+a;
   else ans = 10*(t-1)+a-1;
   cout<<ans;
}

signed main(){
   IOS;
   int tt;
   tt=1;
   //cin>>tt;
   while(tt--)
      solve();
   return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3680kb

input:

5

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

20

output:

11

result:

ok single line: '11'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

44

output:

14

result:

ok single line: '14'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

271828182

output:

82

result:

ok single line: '82'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

314159265

output:

82

result:

ok single line: '82'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1

output:

2

result:

ok single line: '2'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

2

output:

3

result:

ok single line: '3'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3

output:

4

result:

ok single line: '4'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

4

output:

5

result:

ok single line: '5'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

6

output:

7

result:

ok single line: '7'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

7

output:

8

result:

ok single line: '8'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

8

output:

9

result:

ok single line: '9'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

9

output:

10

result:

ok single line: '10'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

10

output:

10

result:

ok single line: '10'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

11

output:

11

result:

ok single line: '11'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

12

output:

11

result:

ok single line: '11'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

13

output:

11

result:

ok single line: '11'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

14

output:

11

result:

ok single line: '11'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

15

output:

11

result:

ok single line: '11'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

16

output:

11

result:

ok single line: '11'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

17

output:

11

result:

ok single line: '11'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

18

output:

11

result:

ok single line: '11'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

19

output:

11

result:

ok single line: '11'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

21

output:

11

result:

ok single line: '11'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

22

output:

12

result:

ok single line: '12'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

23

output:

12

result:

ok single line: '12'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

24

output:

12

result:

ok single line: '12'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

25

output:

12

result:

ok single line: '12'

Test #29:

score: -100
Wrong Answer
time: 0ms
memory: 3704kb

input:

999999998

output:

89

result:

wrong answer 1st lines differ - expected: '88', found: '89'