A. Strange Functions(思维)Educational Codeforces Round 99 (Rated for Div. 2)
原题链接: http://codeforces.com/contest/1455/problem/A
 
 测试样例:
input
5
4
37
998244353
1000000007
12345678901337426966631415
output
1
2
9
10
26
题意: 给定一个整数 n n n,要求你判断在 1 1 1~ n n n之间的数 x x x,进行 g ( x ) = x f ( f ( x ) ) g(x) = \dfrac{x}{f(f(x))} g(x)=f(f(x))x,最后统计 g ( x ) g(x) g(x)有多少个不同的值。其中 f ( x ) f(x) f(x)的操作是将整数 x x x反转再去掉前导 0 0 0。
解题思路: 一道简单的思维题,其实最后我们发现 g ( x ) g(x) g(x)的值只是和 x x x的尾部有关系,若不存在 0 0 0,则为 1 1 1,存在 1 1 1个,则为 10 10 10…(因为 f ( f ( x ) ) f(f(x)) f(f(x))其实就是在去掉尾部的 0 0 0,那么得到的结果不就是这样嘛,仔细思考。)
AC代码
/*
*blog:https://blog.csdn.net/hzf0701
*邮箱:unique_powerhouse@qq.com
*注:文章若有任何问题请私信我或评论区留言,谢谢支持。
*/
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
using namespace std;
typedef long long ll;
const int maxn=1e5;//数组所开最大值
const int mod=1e9+7;//模
const int inf=0x3f3f3f3f;//无穷大
int t;
string s;
void solve(){
    int len=s.size();
    int cnt=1;
    cnt+=len-1;
    cout<<cnt<<endl;
}
int main(){
    while(cin>>t){
        while(t--){
            cin>>s;
            solve();
        }
    }
    return 0;
}

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号