UVA
UVA 10323 Solution
UVA 913 Solution
/*
Name: UVA913
Author: zoom
Date: 31/07/11
*/
using namespace std;
#include<iostream>
int main()
{
int N,temp;
while(cin>>N)
{
temp=((N/2) + 1);
cout<<(2*temp*temp – 3)*3<<endl;
}
}
UVA 621 Solution
/*
Name: UVA621
Author: zoom
Date: 31/07/11
*/
using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>
#include<queue>
#include<map>
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
int main()
{
string str;
int Length,N;
scanf(“%d\n”,&N);
while(N–)
{
getline(cin,str);
Length=str.length();
if(str==”1″ || str==”4″ || str==”78″)
printf(“+\n”);
else if(Length>=2 and str[Length-1]==’5′ and str[Length-2]==’3′)
printf(“-\n”);
else if(str[0]==’9′ and str[Length-1]==’4′)
printf(“*\n”);
else if(Length>=3 and str[0]==’1′ and str[1]==’9′ and str[2]==’0′)
printf(“?\n”);
}
}
UVA 573 Solution
/*
Name: UVA573
Author: zoom
Date: 31/07/11
*/
using namespace std;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<limits>
#include<cmath>
#include<queue>
#include<map>
#define LLU long long unsigned int
#define LLD long long double
#define FOR(i,N) for(int i=0;i<(N);i++)
int main()
{
int H,U,D,F;
while(cin>>H>>U>>D>>F and (H||D||U||F))
{
bool success=false;
int day=1;
double UF=U,Height=0.0F,FF=UF*F/100.0;
while(true)
{
if(UF>0)
Height+=UF;
if(Height>H)
{
success=true;
break;
}
Height-=D;
if(Height<0) break;
UF-=FF;
// cout<<“day=”<<day<<” “<<Height<<” “<<UF<<” “<<D<<“\n”;
day++;
}
if(success) cout<<“success on day “<<day<<endl;
else cout<<“failure on day “<<day<<endl;
}
}