#include <iostream>
using namespace std;
int main()
{
int t,i,r;
double l,w,right_x,p_left_x,n_left_x,y,z;
cin>>t;
for(i=1;i<=t;i++)
{
cin>>r;
l=(100.0/20.0)*r*1.0;
w=(60.0/100.0)*l*1.0;
p_left_x= ((45.0/100.0)*l*1.0);
n_left_x= - p_left_x;
right_x=(l-p_left_x);
y=((w*1.0)/2.0);
z= -y;
cout<<"Case "<<i<<":"<<endl;
cout<<n_left_x<<" "<<y<<endl;
cout<<right_x<<" "<<y<<endl;
cout<<right_x<<" "<<z<<endl;
cout<<n_left_x<<" "<<z<<endl;
}
return 0;
}
Category UVa
UVa – 10812 – Beat The Spread
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
long long int s,d,a,b;
scanf("%lld %lld",&s,&d);
a=(s+d)/2;
b=(s-d)/2;
if((a+b)==s && (a-b)==d && a>=0 && b>=0)
{
printf("%d %d\n",a,b);
}
else
{
printf("impossible\n");
}
}
return 0;
}
UVa – 11805 – Bafana Bafana
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,k,p,i,t,j,a,b,c;
cin>>t;
for(i=1; i<=t; i++)
{
cin>>n>>k>>p;
c=p%n;
a=n-k;
if(a<c)
{
b=c-a;
}
else if(a>=c)
{
b=k+c;
}
cout<<"Case "<<i<<": "<<b<<endl;
}
return 0;
}
UVa – 10071 – Back To High School Physics
#include <stdio.h>
#include <stdlib.h>
int main()
{
int v,t,s;
while((scanf("%d %d",&v,&t))!=EOF)
{
s=2*v*t;
printf("%d\n",s);
}
return 0;
}
UVa – 11547 – Automatic Answer
#include <bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof(a))
#define pb(a) push_back(a)
#define db double
#define ft float
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define sz(x) x.size()
#define qu queue
#define pqu priority_queue
#define vc vector
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define all(x) x.begin(),x.end()
#define CIN ios_base::sync_with_stdio(0); cin.tie(0)
#define loop0(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define stlloop(x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define case(z,x) cout<<"Case "<<i<<": "<<x<<endl
#define case(z) cout<<"Case "<<z<<": "
#define PI 3.14159265358979323846264338328
#define valid(tx,ty) tx>=0 && tx<r && ty>=0 && ty<c
#define MAX 2000
/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
//const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
/*------------------------------------------------*/
using namespace std;
int main()
{
CIN;
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
ll t,a,b,c,n,x;
cin>>t;
loop1(z,t)
{
cin>>n;
a=(n*567)/9;
b=(a+7492)*235;
c=(b/47)-498;
loop0(j,2)
{
x=c%10;
c=c/10;
}
x=abs(x);
cout<<x<<endl;
}
return 0;
}