zoukankan      html  css  js  c++  java
  • BZOJ1263: [SCOI2006]整数划分

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1263

    一眼就可以看出按3拆再乘上最后一个数。。

    一开始写的太过sb。。

    天灾人祸不可避。

    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<cstdlib>
    #include<cstdio>
    #define rep(i,l,r) for (int i=l;i<=r;i++)
    #define down(i,l,r) for (int i=l;i>=r;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define maxn 20050
    #define ll long long
    using namespace std;
    int n,l;
    int ans[maxn];
    ll read(){
        ll x=0,f=1; char ch=getchar();
        while (!isdigit(ch)) {
            if (ch=='-') f=-1; ch=getchar();
        }
        while (isdigit(ch)){
            x=x*10+ch-'0'; ch=getchar();
        }
        return x*f;
    }
    void get(int x){
        rep(i,1,l) ans[i]*=x;
        rep(i,1,l) ans[i+1]+=ans[i]/10,ans[i]=ans[i]%10;
        while (ans[l+1]) {l++,ans[l+1]+=ans[l]/10,ans[l]%=10;}
        //while (ans[l+1]) l++;
    }
    int main(){
        n=read();
        l=1; ans[1]=1;
        while (n>4) {
            get(3); n-=3;
        }
        get(n);
        printf("%d
    ",l);
        if (l<=100) {
            down(i,l,1) printf("%d",ans[i]);
        }
        else {
            down(i,l,l-99) printf("%d",ans[i]);
        }
        puts("");
        return 0;
    }
  • 相关阅读:
    winston写日志(译)
    H5打字机特效
    Flutter 手指放大 平移 旋转 Widget
    51nod1432【贪心】
    死锁的例子
    C# SpinLock用法。
    鼓音效
    rm-rf
    cdoj 1334 郭大侠与Rabi-Ribi Label:贪心+数据结构
    1092 回文字符串(51nod)
  • 原文地址:https://www.cnblogs.com/ctlchild/p/5030801.html
Copyright © 2011-2022 走看看