QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#436892#8795. Mysterious Sequenceucup-team1766#AC ✓0ms4056kbC++142.8kb2024-06-09 03:39:352024-06-09 03:39:35

Judging History

你现在查看的是最新测评结果

  • [2024-06-09 03:39:35]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:4056kb
  • [2024-06-09 03:39:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// if you end up using long double, you need to set the floating point notation to fixed, and set the percision to be very high
typedef long double ld;

// contrsuct umaps like this, unordered_map<long long, int, custom_hash> safe_map;
// FIXED_RANDOM is static so it doesn not get redeclared between function calls
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
		
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


#define INF 2001001001
#define INF2 2e18
#define MOD 1000000007

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for(long long a = b; a < c; a++)
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back 
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define pll pair<ll, ll>
#define pii pair<int, int>
#define tp make_tuple

// first four are north, west, east ,south
int dir1[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dir2[] = {0, 1, 0, -1, 1, -1, 1, -1};

int main() {
	// apparently this does fast i/o
	cin.tie(0) , ios::sync_with_stdio(0);
	
	// use this if you read in from a file
	/*
	freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
	*/
	
	stringstream ss;
	
	// Do it once. Do it right.
	// Read the problem statement carefully
	// Plan out the steps in words on a piece of paper before implementing
	// after RTE(obviously) but also WA, run valgrind!!!
	
	cout << fixed << setprecision(8);
	// if you use ld, use the above and don't use string stream
	
	// use instead of ceil(a, b) if a and b are positive
	// (a + b - 1) / b
	
	double a, b;
	int n;
	double x1, xn;
	cin >> a >> b;
	cin >> n;
	cin >> x1 >> xn;
	if(n == 2){
		cout << x1 << " " << xn << "\n";
		return 0;
	}
	double fact1 = 1, fact2 = a, con1 = 0, con2 = b*x1;
	for(int i = 4; i <= n; i++){
		double temp1, temp2;
		temp1 = a*fact2 + b*fact1;
		temp2 = a*con2 + b*con1;
		fact1 = fact2;
		con1 = con2;
		fact2 = temp1;
		con2 = temp2;
		//cout << fact2 << " " << con2 << "\n";
	}
	double x2 = (xn-con2)/fact2;
	vector<double> ans;
	ans.pb(x1);
	ans.pb(x2);
	double curr2 = x2, curr1 = x1;
	for(int i = 3; i < n; i++){
		double temp = a*curr2 + b*curr1;
		ans.pb(temp);
		curr1 = curr2;
		curr2 = temp;
	}
	ans.pb(xn);
	for(auto d : ans){
		cout << d << " ";
	}
	cout << endl;
	cout << ss.str();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3912kb

input:

1.0 1.0 10 1 10

output:

1.00000000 -0.32352941 0.67647059 0.35294118 1.02941176 1.38235294 2.41176471 3.79411765 6.20588235 10.00000000 

result:

ok 10 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

1 1 2 1 100

output:

1.00000000 100.00000000

result:

ok 2 numbers

Test #3:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

1 1 5 50 100

output:

50.00000000 0.00000000 50.00000000 50.00000000 100.00000000 

result:

ok 5 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

0.25 0.25 10 1 1

output:

1.00000000 55.87553648 14.21888412 17.52360515 7.93562232 6.36480687 3.57510730 2.48497854 1.51502146 1.00000000 

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

0.25 0.63 6 93 12

output:

93.00000000 -14.20480796 55.03879801 4.81067049 35.87711037 12.00000000 

result:

ok 6 numbers

Test #6:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

0.25 0.80 10 5 63

output:

5.00000000 78.76953618 23.69238405 68.93872496 36.18858848 64.19812709 45.00040255 62.60860231 51.65247262 63.00000000 

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

0.25 0.99 3 18 30

output:

18.00000000 48.72000000 30.00000000 

result:

ok 3 numbers

Test #8:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

0.28 0.64 9 6 10

output:

6.00000000 20.95040335 9.70611294 16.12596977 10.72718381 13.32423212 10.59618263 11.49443969 10.00000000 

result:

ok 9 numbers

Test #9:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

0.31 0.40 7 10 49

output:

10.00000000 240.11506400 78.43566984 120.36108325 68.68620374 69.43715646 49.00000000 

result:

ok 7 numbers

Test #10:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

0.32 0.28 5 36 6

output:

36.00000000 10.12137681 13.31884058 7.09601449 6.00000000 

result:

ok 5 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 4052kb

input:

0.35 0.65 10 86 82

output:

86.00000000 79.53392479 83.73687368 81.00495690 82.78070280 81.62646796 82.37672061 81.88905639 82.20603813 82.00000000 

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

0.36 0.68 8 72 59

output:

72.00000000 38.23991864 62.72637071 48.58463813 60.14440181 54.68953858 60.58642712 59.00000000 

result:

ok 8 numbers

Test #13:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

0.43 0.61 2 93 84

output:

93.00000000 84.00000000

result:

ok 2 numbers

Test #14:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

0.46 0.96 6 65 35

output:

65.00000000 -16.61742366 54.75598512 9.23502644 56.81385787 35.00000000 

result:

ok 6 numbers

Test #15:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

0.50 0.90 4 19 1

output:

19.00000000 -6.56521739 13.81739130 1.00000000 

result:

ok 4 numbers

Test #16:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

0.54 0.35 3 16 22

output:

16.00000000 30.37037037 22.00000000 

result:

ok 3 numbers

Test #17:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

0.55 0.89 10 74 13

output:

74.00000000 -48.32193708 39.28293461 -21.40090996 23.19131132 -6.29158864 17.17989332 3.84942744 17.40729015 13.00000000 

result:

ok 10 numbers

Test #18:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

0.56 0.36 3 31 88

output:

31.00000000 137.21428571 88.00000000 

result:

ok 3 numbers

Test #19:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

0.57 0.93 7 71 48

output:

71.00000000 -34.08056536 46.60407774 -5.13060147 40.41734946 18.26642982 48.00000000 

result:

ok 7 numbers

Test #20:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

0.58 0.41 8 30 69

output:

30.00000000 89.43212168 64.17063058 73.88613562 69.16391720 70.40838758 69.19407085 69.00000000 

result:

ok 8 numbers

Test #21:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

0.58 0.49 6 31 96

output:

31.00000000 99.55761354 72.93341585 91.08461183 88.56644863 96.00000000 

result:

ok 6 numbers

Test #22:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

0.61 0.29 8 62 25

output:

62.00000000 34.40765126 38.96866727 33.74910590 31.88786810 29.23884025 27.08317431 25.00000000 

result:

ok 8 numbers

Test #23:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

0.63 0.89 9 37 85

output:

37.00000000 -5.88785330 29.22065242 13.16882159 34.30273825 33.33097631 51.52795212 62.12717875 85.00000000 

result:

ok 9 numbers

Test #24:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

0.64 0.67 2 74 42

output:

74.00000000 42.00000000

result:

ok 2 numbers

Test #25:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

0.65 0.56 2 94 96

output:

94.00000000 96.00000000

result:

ok 2 numbers

Test #26:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

0.65 0.90 10 97 23

output:

97.00000000 -61.70357628 47.19267542 -24.85797963 26.31572112 -5.26696294 20.26062310 8.42913837 23.71350072 23.00000000 

result:

ok 10 numbers

Test #27:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

0.67 0.88 4 70 42

output:

70.00000000 0.54782151 61.96704041 42.00000000 

result:

ok 4 numbers

Test #28:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

0.69 0.39 10 2 27

output:

2.00000000 22.36590769 16.21247630 19.90931265 20.06029149 21.60623306 22.73181449 24.11138289 25.50226184 27.00000000 

result:

ok 10 numbers

Test #29:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

0.69 0.57 4 88 47

output:

88.00000000 11.84360960 58.33209062 47.00000000 

result:

ok 4 numbers

Test #30:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

0.71 0.89 8 4 41

output:

4.00000000 6.83889036 8.41561216 12.06169705 16.05369973 22.13303719 30.00224916 41.00000000 

result:

ok 8 numbers

Test #31:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

0.72 0.49 8 21 48

output:

21.00000000 19.94044237 24.64711851 27.51674209 31.88914237 36.44338613 41.86491777 48.00000000 

result:

ok 8 numbers

Test #32:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

0.74 0.58 3 57 29

output:

57.00000000 -5.48648649 29.00000000 

result:

ok 3 numbers

Test #33:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

0.76 0.70 2 91 18

output:

91.00000000 18.00000000

result:

ok 2 numbers

Test #34:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

0.77 0.36 10 31 25

output:

31.00000000 5.21497209 15.17552851 13.56254690 15.90635137 17.13040744 18.91670023 20.73280585 22.77427259 25.00000000 

result:

ok 10 numbers

Test #35:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

0.77 0.96 8 78 68

output:

78.00000000 -40.09755701 44.00488110 -4.60989628 38.69506573 25.36970018 56.68193224 68.00000000 

result:

ok 8 numbers

Test #36:

score: 0
Accepted
time: 0ms
memory: 4044kb

input:

0.78 0.52 7 73 77

output:

73.00000000 8.72754751 44.76748705 39.45696461 54.05552566 62.68093161 77.00000000 

result:

ok 7 numbers

Test #37:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

0.78 0.69 4 42 97

output:

42.00000000 57.29790511 73.67236599 97.00000000 

result:

ok 4 numbers

Test #38:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

0.78 0.70 10 54 99

output:

54.00000000 -13.01288635 27.64994865 12.45793950 29.07215686 31.39684000 44.84004500 56.95302310 75.81138952 99.00000000 

result:

ok 10 numbers

Test #39:

score: 0
Accepted
time: 0ms
memory: 4052kb

input:

0.78 0.76 10 97 83

output:

97.00000000 -43.73473696 39.60690517 -2.34501405 28.27213697 20.27005615 37.29746790 44.49726763 63.05394436 83.00000000 

result:

ok 10 numbers

Test #40:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

0.78 0.95 10 100 32

output:

100.00000000 -63.26957882 45.64972852 -24.49931163 24.25777903 -4.35327841 19.64933292 11.19086519 27.39574112 32.00000000 

result:

ok 10 numbers

Test #41:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

0.79 0.90 10 98 42

output:

98.00000000 -58.24691463 42.18493744 -19.09612258 22.88050686 0.88909009 21.29483734 17.62310258 33.08760465 42.00000000 

result:

ok 10 numbers

Test #42:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

0.81 0.48 10 97 1

output:

97.00000000 -38.25750168 15.57142364 -5.75074766 2.81617774 -0.47925491 0.96356884 0.55044841 0.90837625 1.00000000 

result:

ok 10 numbers

Test #43:

score: 0
Accepted
time: 0ms
memory: 4056kb

input:

0.81 0.86 10 20 100

output:

20.00000000 -3.33284287 14.50039728 8.87907693 19.66239397 23.56254527 35.99532048 49.41999852 70.98617441 100.00000000 

result:

ok 10 numbers

Test #44:

score: 0
Accepted
time: 0ms
memory: 4040kb

input:

0.84 0.85 10 74 95

output:

74.00000000 -36.29080488 32.41572390 -3.61797607 24.51426542 17.51670330 35.55115638 44.75216916 67.81030502 95.00000000 

result:

ok 10 numbers

Test #45:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

0.88 0.37 10 3 96

output:

3.00000000 29.02182849 26.64920907 34.18938052 39.94686222 47.80330955 56.84725142 67.71280578 80.62075211 96.00000000 

result:

ok 10 numbers

Test #46:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

0.91 0.50 10 100 98

output:

100.00000000 -22.58685785 29.44595935 15.50239408 28.83015829 33.98664109 45.34292254 58.25538005 75.68385711 98.00000000 

result:

ok 10 numbers

Test #47:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

0.94 0.48 10 44 97

output:

44.00000000 -1.58274344 19.63222117 17.69457105 26.05636294 32.98637527 43.51424697 56.73685228 74.21947969 97.00000000 

result:

ok 10 numbers

Test #48:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

0.94 0.54 10 28 95

output:

28.00000000 0.45254631 15.54539353 14.85704492 22.36013473 29.04133091 39.37332381 52.69324307 70.79324334 95.00000000 

result:

ok 10 numbers

Test #49:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

0.95 0.57 10 2 94

output:

2.00000000 9.22728417 9.90591997 14.67017595 19.58304153 26.96588974 36.77992893 50.31148963 68.76047464 94.00000000 

result:

ok 10 numbers

Test #50:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

0.98 0.90 10 21 99

output:

21.00000000 -8.21319348 10.85107038 3.24217484 12.94329469 15.60238615 26.93930365 40.44266512 63.87918510 99.00000000 

result:

ok 10 numbers

Extra Test:

score: 0
Extra Test Passed