water~1
1491 단어 물 문제
http://poj.org/problem?id=1503
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
string ans="0";
string inputs[107];
int counts;
string adds(const string a,const string b)
{
string c;
int temp=0;
int i,j;
for(i=a.size()-1,j=b.size()-1;i>=0 && j>=0;i--,j--)
{
c.append(1,((a[i]+b[j]-96+temp) % 10)+48);
temp=(a[i]+b[j]-96+temp)/10;
}
if(i<0)
{
while(j>=0)
{
c.append(1,(b[j]-48+temp)%10+48);
temp=(b[j]-48+temp)/10;
j--;
}
}
else
{
while(i>=0)
{
c.append(1,(a[i]-48+temp)%10+48);
temp=(a[i]-48+temp)/10;
i--;
}
}
if(temp)
c.append(1,temp+48);
reverse(c.begin(),c.end());
return c;
}
void waterit()
{
for(int i=0;i<counts;i++)
ans=adds(ans,inputs[i]);
cout<<ans<<endl;
}
int main()
{
// ifstream cin("1.txt");
int i=0;
while(cin>>inputs[i])i++;
counts=i-1;
waterit();
return 0;
};
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
hdu 2045 쉽 지 않 은 시리즈 (3) - LELE 의 RPG 난제 (전달)만약 당신 이 Cole 이 라면, 나 는 당신 이 반드시 어떻게 든 LELE 가 이 문 제 를 해결 하도록 도와 줄 것 이 라 고 생각 합 니 다.그렇지 않 았 다 면, 예 쁘 고 죽 고 싶 은 콜 녀 들 을 봐 서...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.