列表

详情


NC243986. Kooky Clock

描述

Cuber QQ likes observing the clock when he is bored.

This time, Cuber QQ buys a kooky clock, the clock has three hands. Unlike ordinary clocks, the three hands of this clock are connected one by one, i.e., the first hand is at the innermost position, and its rotating center is the center of the dial. The rotating center of the second hand is the end of the first hand (that is, with the rotation of the first hand, the rotating center of the second hand will change); similarly, the third hand is rotating around the end of the second hand.
The lengths of the three hands are l_1,l_2 and l_3 respectively, and their rotating speed is also different, the time required for three hands to rotate in a 360-degree is t_1 second, t_2 second and t_3 second.



Cuber QQ assumes that the center of the clock is the origin of the axes and the end of three hands are at (0,l_1), and at begining.
He now wants to know the position of the end of the third hand after the hands of the clock have rotated T seconds.

输入描述

The first line contains one integer T (0\le T\le 1000), which denotes the times the three hands have rotated.

The second line contains three integers l_1,l_2 and l_3 (1\le l_1,l_2,l_3 \le 1000), denotes the length of each hand.

The third line contains three integers t_1,t_2 and t_3 (1\le t_1,t_2,t_3 \le 1000), 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 (x,y).

Your answer is considered correct if its absolute or relative error does not exceed 10^{-6}.

Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if \frac{|a - b|}{\max{(1,|b|)}} \le 10^{-6}.

示例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)

上一题