#include <iostream>
#include <iomanip>
using namespace std;
typedef struct
{
double x,y;
}Point;
int main()
{
Point p1,p2,p3,p4;
cout<<fixed<<setprecision(3);
while(cin>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y>>p4.x>>p4.y)
{
if(p1.x==p3.x&&p1.y==p3.y) swap(p1,p2);
else if(p1.x==p4.x&&p1.y==p4.y) swap(p1,p2),swap(p3,p4);
else if(p2.x==p4.x&&p2.y==p4.y) swap(p3,p4);
Point p5;
p5.x=p1.x+p4.x-p2.x;
p5.y=p1.y+p4.y-p2.y;
cout<<p5.x<<" "<<p5.y<<endl;
}
return 0;
}
2020年7月31日 星期五
10242 - Fourth Point !!
程式碼:
2020年7月30日 星期四
【Hamilton】You'll Be Back 歌詞筆記
hurl:丟
go by:經過
estrangement:疏遠;隔閡
time will tell:時間會證明一切
serve ...... well:對人有所幫助、助益
through it all:經歷一切
when push comes to shove:一旦不得已時
change the subject:改變話題
subject:話題、臣民
until my dying day:一直到死
go by:經過
estrangement:疏遠;隔閡
time will tell:時間會證明一切
serve ...... well:對人有所幫助、助益
through it all:經歷一切
when push comes to shove:一旦不得已時
change the subject:改變話題
subject:話題、臣民
until my dying day:一直到死
c660: 墨西哥波浪舞
程式碼:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
getline(cin,s);
for(int i=0;i<s.size();i++)
{
if(s[i]==' ')
{
//cout<<s<<endl;
continue;
}
for(int j=0;j<s.size();j++)
{
if(s[j]==' ') cout<<s[j];
else if(i==j) // capital
{
if('a'<=s[j]&&s[j]<='z') cout<<char(s[j]-'a'+'A');
else cout<<s[j];
}
else //non-capital
{
if('a'<=s[j]&&s[j]<='z') cout<<s[j];
else cout<<char(s[j]-'A'+'a');
}
}
cout<<endl;
}
return 0;
}
10056 - What is the Probability ?
程式碼:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
double s,n,p,k,q;
cin>>s;
cout<<fixed<<setprecision(4);
while(s--)
{
double r,a0;
cin>>n>>p>>k;
q=1-p;
if(pow(q,n)==1)
cout<<"0.0000"<<endl;
else
cout<<p*pow(q,k-1)/(1-pow(q,n))<<endl;
}
return 0;
}
10038 - Jolly Jumpers
程式碼:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n,tmp;
while(cin>>n)
{
vector<int> sq;
vector<int> diff;
for(int i=0;i<n;i++)
{
cin>>tmp;
sq.push_back(tmp);
}
for(int i=0;i<sq.size()-1;i++)
diff.push_back(abs(sq[i]-sq[i+1]));
sort(diff.begin(),diff.end());
int i;
for(i=0;i<n-1;i++)
{
if(i+1!=diff[i]) break;
}
if(i==n-1) cout<<"Jolly"<<endl;
else cout<<"Not jolly"<<endl;
}
return 0;
}
2020年7月29日 星期三
10041 - Vito's Family
程式碼:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int r,cases,n,mid;
cin>>cases;
while(cases--)
{
cin>>r;
vector<int> nightbor;
for(int i=0;i<r;i++)
{
cin>>n;
nightbor.push_back(n);
}
sort(nightbor.begin(),nightbor.end());
mid=r/2;
int sum=0;
for(int i=0;i<nightbor.size();i++)
{
sum+=abs(nightbor[i]-nightbor[mid]);
}
cout<<sum<<endl;
}
return 0;
}
10190 - Divide, But Not Quite Conquer!
程式碼:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n,m;
while(cin>>n>>m)
{
vector<int> sq;
if(n<=1||m<=1)
{
cout<<"Boring!"<<endl;
continue;
}
while(n%m==0)
{
sq.push_back(n);
n/=m;
}
if(n!=1) cout<<"Boring!"<<endl;
else
{
for(int i=0;i<sq.size();i++)
{
if(i!=sq.size()-1)
cout<<sq[i]<<" ";
else
cout<<sq[i]<<" 1"<<endl;
}
}
}
return 0;
}
2020年7月28日 星期二
【Hamilton】The Room Where It Happens 歌詞筆記
Secretary:部長
good old:有名的人
renamed ... after:把...重新命名為...
whatever it takes:不惜代價
hate the sin, love the sinner:(甘地名言)
Virginians:維吉尼亞人
diametrically opposed:完全相反的
Bros:兄弟
unprecedented:史無前例的
pièce de résistance:最重要的事
how the sausage gets made:私底下做的事
doorstep:門口
disarray:混亂
nowhere else to turn:無處容身
join the fray:參與辯論
pieces:棋
grapple with sth:設法克服
quid pro quo:交換條件
see how it goes:看看事情會怎麼發展
In God we trust:(美國格言)我們信仰上帝
sell ...... down the river:出賣、背叛
skin in the game:(商業上)參與某事
outlive:活得比....長
fall for:相信
hold one’s nose:睜一隻眼閉一隻眼
save the day:扭轉危機
get a say:參與活動並影響或做出決策
trade away:賣掉、出賣
good old:有名的人
renamed ... after:把...重新命名為...
whatever it takes:不惜代價
hate the sin, love the sinner:(甘地名言)
Virginians:維吉尼亞人
diametrically opposed:完全相反的
Bros:兄弟
unprecedented:史無前例的
pièce de résistance:最重要的事
how the sausage gets made:私底下做的事
doorstep:門口
disarray:混亂
nowhere else to turn:無處容身
join the fray:參與辯論
pieces:棋
grapple with sth:設法克服
quid pro quo:交換條件
see how it goes:看看事情會怎麼發展
In God we trust:(美國格言)我們信仰上帝
sell ...... down the river:出賣、背叛
skin in the game:(商業上)參與某事
outlive:活得比....長
fall for:相信
hold one’s nose:睜一隻眼閉一隻眼
save the day:扭轉危機
get a say:參與活動並影響或做出決策
trade away:賣掉、出賣
10221 - Satellites
解題心得:
弧長=2*pi*半徑*a/360
弦長=2*sin(a/2)*半徑
pi 可用2acos0得知
三角函數參數預設弧度,轉為角度要另外乘上pi/180
程式碼:
弧長=2*pi*半徑*a/360
弦長=2*sin(a/2)*半徑
pi 可用2acos0得知
三角函數參數預設弧度,轉為角度要另外乘上pi/180
程式碼:
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
#define PI 2*acos(0)
int main()
{
double s,a;
string type;
cout<<fixed<<setprecision(6);
while(cin>>s>>a>>type)
{
if(a>180) a=360-a;
if(type=="min") a/=60;
cout<<2*PI*(s+6440)*(a/360.0)<<" "<<2*sin(a/2.0*PI/180)*(6440+s)<<endl;
}
return 0;
}
272 - TEX Quotes
程式碼:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int count=0;
string text;
while(getline(cin,text))
{
for(int i=0;i<text.size();i++)
{
if(text[i]=='"')
{
if(count%2==0) cout<<"``";
else cout<<"''";
count++;
}
else
cout<<text[i];
}
cout<<endl;
}
return 0;
}
2020年7月27日 星期一
10235 - Simply Emirp
程式碼:
#include <iostream>
#include <cmath>
using namespace std;
int isPrime(int n)
{
for(int i=2;i<=n/2;i++)
{
if(n%i==0)
return 0;
}
return 1;
}
int main()
{
int n;
while(cin>>n)
{
int reverse=0,copy=n;
while(copy>0)
{
reverse=reverse*10+copy%10;
copy/=10;
}
if(isPrime(n)&&isPrime(reverse)&&n!=reverse)
cout<<n<<" is emirp."<<endl;
else if(isPrime(n))
cout<<n<<" is prime."<<endl;
else
cout<<n<<" is not prime."<<endl;
}
return 0;
}
訂閱:
文章 (Atom)