• 代码仓库


    刷算法题的AC代码保存在这里,以备日后查询。代码的插入顺序类似于栈。

    //2016年5月14日00:01:51
    #include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main()
    {
        stringstream ssm;
        string strA;
        string strAns;
        ll a,b;
        bool isNegative=0;
    
        cin>>a>>b;
    
        a+=b;
    
        a<0?(isNegative=1):(isNegative=0);
    
        a=abs(a);
        ssm<<a;
        ssm>>strA;
    
        for(int i=strA.length()-1,j=1; i>0; i--,j++)
        {
            strAns=strA[i]+strAns;
            if(j%3==0)
            {
                strAns=","+strAns;
            }
        }
        strAns=strA[0]+strAns;
    
        isNegative==1?(cout<<"-"<<strAns):(cout<<strAns);
    
        return 0;
    }
    
    
    //网上看到的别人的代码http://www.nowcoder.com/profile/899290/codeBookDetail?submissionId=149259
    #include <stdio.h>
    int main()
    {
      int a,b;
      int sum;
      while(scanf("%d%d
    ",&a,&b) != EOF){
            sum = a+b;
        if(sum < 0){
        printf("-");
        sum = -sum;
        }
        if(sum>=1000000){
            printf("%d,%03d,%03d
    ",sum/1000000, (sum/1000)%1000, sum%1000);
        }
        else if(sum >= 1000){
            printf("%d,%03d
    ",sum/1000,sum%1000);
        } else{
            printf("%d
    ", sum);
        }
      }
      return 0;
    }
    
    #include<iostream>
    using namespace std;
    int main()
    {
    	int floor=0;
    	int eleFloor=0;
    	int arrFloor[99999]={0};
    	int top=1; 
    	
    	while(cin>>floor)
    	{
    		int f=1;//floor is new
    		for(int i=1;i<top;i++)
    		{
    			if(floor==arrFloor[i])
    			{
    				f=0;
    				break;
    			}
    		}
    		
    		if(f==1)
    		{
    			arrFloor[top++]=floor;
    		}
    		
    		if(elefloor-floor <0)
    		{
    			-(elefloor-floor)*6+5;
    		}
    	}
    }
    
    #include<iostream>
    using namespace std;
    int main()
    {
    	int floor=0;
    	int eleFloor=0;
    	int sumTime=0;
    	int arrOldFloor[99999]={0};
    	int top=1; 
    	
    	while(cin>>floor)
    	{
    		if(arrOldFloor[floor]==0)
    		{
    			arrOldFloor[floor]=1;
    			
    			if(eleFloor-floor <0)
    			{
    				sumTime+=(-(eleFloor-floor))*6+5;
    			}
    			
    			if(eleFloor-floor >0)
    			{
    				sumTime+=(eleFloor-floor)*4+5;
    			}
    		}
    		
    		
    	}
    	cout<<sumTime;
    }
    
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string engNum[]={"zero","one","two","three","four","five","six","seven","eight","nine"};
        stringstream ssm;
        string strNum,strSum;
        int sum=0;
         
        cin>>strNum;
         
        for(int i=0;i<strNum.length();i++)
        {
            sum+=(strNum[i]-'0');
        }
         
        ssm<<sum;
        ssm>>strSum;
         
        for(int i=0;i<strSum.length()-1;i++)
        {
            cout<<engNum[strSum[i]-'0']<<" ";
        }
        cout<<engNum[strSum[strSum.length()-1]-'0'];
         
         
        return 0;
    }
    
  • 相关阅读:
    HDU 3501 Calculation 2 ——Dirichlet积
    BZOJ 1101 [POI2007]Zap ——Dirichlet积
    BZOJ 1257 [CQOI2007]余数之和sum ——Dirichlet积
    SGU 194 Reactor Cooling ——网络流
    BZOJ 1497 [NOI2006]最大获利 ——网络流
    BZOJ 2705 [SDOI2012]Longge的问题 ——Dirichlet积
    BZOJ 1653 [Usaco2006 Feb]Backward Digit Sums ——搜索
    BZOJ 1861 [Zjoi2006]Book 书架 ——Splay
    BZOJ 3130 [Sdoi2013]费用流 ——网络流
    BZOJ 3990 [SDOI2015]排序 ——搜索
  • 原文地址:https://www.cnblogs.com/sundy-lee/p/5432364.html
Copyright © 2020-2023  润新知