zoukankan      html  css  js  c++  java
  • A/B 高精度

    P1480 洛谷

    做了A+B Problem,A/B Problem不是什么问题了吧! 

    #include<bits/stdc++.h>
    #define LL long long
    using namespace std;
    int a[11000000],a2[110000000];
    int n1,n2,b;
    char x[110000000];
    int main()
    {
    	scanf("%s",x);
    	cin>>b;
    	n1=strlen(x);
    	int k=0;
    	for(int i=0;i<n1;i++)
    	{
    		a[k++]=x[i]-48;//从char转int 
    	}
    	if(b==0)
    	{
    		cout<<0;//如果一个除数是0,输出0 
    	}
    	else
    	{
    		if(x=="0")
    		{
    			cout<<0;//如果一个除数是0,输出0 
    		}
    		else
    		{
    			int j=0;
    			int pd=0;
    			int k2=0;
    			for(int i=0;i<n1;i++)
    			{
    				int sum=a[i]+k2*10;//除操作 
    				int x=sum/b;
    				k2=sum%b;
    				if(x||j)
    				{
    					pd=-1;
    					a2[j++]=x;
    				}
    			}
    			if(pd==0)
    			{
    				cout<<0;
    				return 0;
    			}
    			for(int i=0;i<j;i++)
    			{
    				cout<<a2[i];//输出 
    			}
    		}
    	}
    }
    

      这是一道高精除低精

  • 相关阅读:
    linux ipsec
    inotify+rsync
    多实例tomcat
    Http和Nginx反代至Tomcat(LNMT、LAMT)
    cisco ipsec
    ansible基础
    Qt 汉字乱码
    Model/View
    面对焦虑
    QT中QWidget、QDialog及QMainWindow的区别
  • 原文地址:https://www.cnblogs.com/dai-jia-ye/p/9263148.html
Copyright © 2011-2022 走看看