thamcacphongbansol

 avatar
quoc14
c_cpp
5 months ago
1.1 kB
2
Indexable
caidat
#include <iostream>

using namespace std;

int n, e, k, t;

float a[105][105];
float nguon[105];
float dich[105];
float ans_jang, ans_kang;
int index_jang, index_kang;
void solve(int testcase) {
	cin >> n >> e >> k >> t;
	
	for (int i = 1; i <= e; i++) {
		int u, v;
		float c;
		cin >> u >> v >> c;
		a[u][v] = c;
	}
	
	int left = 0;
	int right = 9;
	nguon[1] = 1;
	
	ans_jang = -1;
	ans_kang = -1;
	int ok = 0;
	while (true) {
		if (ok == 1) break;
		if (t >= left && t <= right) {
			
			for (int i = 1; i <= n; i++) {
				if (nguon[i] > ans_jang) {
					ans_jang = nguon[i];
				}
			}
			ok = 1;
			break;			
		}
		
		for (int i = 1; i <= n; i++) {
			if (nguon[i] != 0) {
				for (int j = 1; j <= n; j++) {
					dich[j] += (nguon[i] * a[i][j]);
				}
			}
		}
		
		
		for (int i = 1; i <= n; i++) {
			nguon[i] = dich[i];
			dich[i] = 0;
		}
		left = left + 10;
		right = left + 9;
	}
	

	cout << ans_jang << endl;
	cout << endl;

}

int main() {
	freopen("Text.txt", "r", stdin);
	for (int i = 1; i <= 1; i++) {
		solve(i);
	}	
}
Leave a Comment