加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

L1-046 整除光棍 [大数相除]

发布时间:2020-12-14 04:38:00 所属栏目:大数据 来源:网络整理
导读:写都写了,当大数相除模版吧 #includeiostream #include cstdio #include string .h #include string #include math.h #include map #define maxn 10005 using namespace std;typedef long long ll; int n,p; string s; int ans[maxn]; bool judge( string s

写都写了,当大数相除模版吧

#include<iostream>
#include<cstdio>
#include<string.h>
#include<string>
#include<math.h>
#include<map>
#define maxn 10005
using namespace std;
typedef long long ll;
int n,p;
string s;
int ans[maxn];
bool judge(string ss)
{
    int l=ss.length();
    int sum=0;
    for(int i=0;i<l;i++)
    {
        sum=sum*10+s[i]-0;
        if(sum<n)
        {
            ans[p++]=0;
        }
        else
        {
            ans[p++]=sum/n;
            sum=sum%n;
        }
    }
    if(sum==0)
        return true;
    else
        return false;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<1000;i++)
    {
        s=s+"1";
        p=0;
        memset(ans,0,sizeof(ans));
        if(judge(s))
        {
            int flag=1;
            for(int i=0;i<p;i++)
            {
                if(ans[i]==0&&flag)
                    continue;
                else
                {
                    printf("%d",ans[i]);
                    flag=0;
                }
            }
            printf(" %dn",s.length());
            break;
        }
    }
    return 0;
}
View Code

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读