NC243986. Kooky Clock
描述
输入描述
The first line contains one integer (), which denotes the times the three hands have rotated.
The second line contains three integers and (), denotes the length of each hand.
The third line contains three integers and (), denotes the time of each hand required to rotate in a 360-degree.
输出描述
Print two numbers to denote the position of the third hand is .
Your answer is considered correct if its absolute or relative error does not exceed .
Formally, let your answer be , and the jury's answer be . Your answer is accepted if and only if .
示例1
输入:
2 1 2 3 3 2 1
输出:
-0.8660254038 4.5000000000
说明:
C++(clang++ 11.0.1) 解法, 执行用时: 4ms, 内存消耗: 468K, 提交时间: 2022-10-08 19:37:34
#include<bits/stdc++.h> using namespace std; const double pai=2*3.1415926535; double T,l1,l2,l3,t1,t2,t3; int main(){ cin>>T>>l1>>l2>>l3>>t1>>t2>>t3; printf("%.15lf ",l1*sin(pai*T/t1)+l2*sin(pai*T/t2)+l3*sin(pai*T/t3)); printf("%.15lf",l1*cos(pai*T/t1)+l2*cos(pai*T/t2)+l3*cos(pai*T/t3)); }
pypy3 解法, 执行用时: 82ms, 内存消耗: 53788K, 提交时间: 2022-10-16 15:05:46
import math t = int(input()) l1,l2,l3 = map(int,input().split()) t1,t2,t3 = map(int,input().split()) d1,d2,d3 = map(lambda x:math.pi*2*(t/x),(t1,t2,t3)) x = l1*math.cos(d1)+l2*math.cos(d2)+l3*math.cos(d3) y = l1*math.sin(d1)+l2*math.sin(d2)+l3*math.sin(d3) print("%.10f %.10f" % (y,x))
Python3 解法, 执行用时: 45ms, 内存消耗: 4868K, 提交时间: 2022-10-07 11:38:35
import math a=int(input()) c=list(map(int,input().split())) b=list(map(int,input().split())) x=0 y=0 for i in range(3): x=x+c[i]*math.sin((a%b[i])/b[i]*(2*math.pi)) y=y+c[i]*math.cos((a%b[i])/b[i]*(2*math.pi)) print('%.10f' % x +" "+"%.10f" % y)