zoukankan      html  css  js  c++  java
  • U68641 划水(swim.pas/c/cpp)

    U68641 划水(swim.pas/c/cpp)

    题目背景

    小小迪带你划水。

    题目描述

    原题

    输入输出格式

    输入格式:

    第一行一个数 T。 接下来 T 行每行一个数表示 n

    输出格式:

    输出 T 行每行一个整数表示这个数的子数

    输入输出样例

    输入样例#1: 
    2
    1234567890123456789
    1021
    
    输出样例#1: 
    332876913
    1158

    sol:一个个拆出来过于睿智,所以我们一位位讨论贡献,十分简单
    // luogu-judger-enable-o2
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    typedef long long ll;
    inline ll read()
    {
        ll s=0;
        bool f=0;
        char ch=' ';
        while(!isdigit(ch))
        {
            f|=(ch=='-'); ch=getchar();
        }
        while(isdigit(ch))
        {
            s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
        }
        return (f)?(-s):(s);
    }
    #define R(x) x=read()
    inline void write(ll x)
    {
        if(x<0)
        {
            putchar('-'); x=-x;
        }
        if(x<10)
        {
            putchar(x+'0');    return;
        }
        write(x/10);
        putchar((x%10)+'0');
        return;
    }
    #define W(x) write(x),putchar(' ')
    #define Wl(x) write(x),putchar('
    ')
    const int N=100005;
    const ll Mod=1000000007;
    int T,n;
    ll Bin[N],SBin[N];
    char S[N];
    int main()
    {
        int i;
        R(T);
        Bin[0]=SBin[0]=1;
        for(i=1;i<=100000;i++)
        {
            SBin[i]=(SBin[i-1]+(Bin[i]=Bin[i-1]*10%Mod))%Mod;
            Bin[i]=Bin[i-1]*10%Mod;
        }
        while(T--)
        {
            ll ans=0,Sum=1;
            scanf("%s",S+1);
            n=strlen(S+1);
            for(i=1;i<=n;i++)
            {
                int oo=S[i]-'0';
                if(!oo) continue;
                ans=(ans+Sum*SBin[n-i]%Mod*oo)%Mod;
                Sum++;
            }
            Wl(ans);
        }
        return 0;
    }
    /*
    input
    1
    1234567890123456789
    output
    332876913
    
    input
    1
    1021
    output
    1158
    */
    View Code
     
  • 相关阅读:
    js实现点击上下按钮,图片向上向下循环滚动切换
    jquery实现点击进入新的页面。(jquery实现超链接)
    jquery实现鼠标移入移除背景图片切换
    C:WindowsSystem32driversetchosts文件显示
    网页添加qq咨询
    本地虚拟站点创建
    ftp获取mysql数据库方法
    数论基础
    最小费用最大流
    AC自动机 hdu2222
  • 原文地址:https://www.cnblogs.com/gaojunonly1/p/10713631.html
Copyright © 2011-2022 走看看