#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template ostream& operator<<(ostream& os, const set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const unordered_set& se){for(T x : se) os << x << " "; os << "\n"; return os;} template ostream& operator<<(ostream& os, const atcoder::segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const atcoder::lazy_segtree& seg){int n = seg.max_right(0, [](S){return true;}); rep(i, n) os << seg.get(i) << (i == n - 1 ? "\n" : " "); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} using P = pair; int main(){ int N, M, C; cin >> N >> M >> C; vector> G(N, vector

(N, {-1, -1})); rep(_, M){ int u, v, r, w; cin >> u >> v >> r >> w; u--; v--; G[u][v] = {r, w}; G[v][u] = {r, w}; } for(int c = 1; c <= C; c++){ vector D(N, -1); D[0] = c; set> E; rep(i, N) E.insert({D[i], i}); while(E.size()){ auto it = prev(E.end()); auto [money_from, from] = *it; E.erase(it); if(money_from == -1) continue; vector cand; for(auto [tmp, to] : E) cand.push_back(to); for(int to : cand){ auto [r, w] = G[from][to]; if(r == -1) continue; int money_to = money_from - money_from / r - w; if(money_to > D[to]){ E.erase({D[to], to}); D[to] = money_to; E.insert({D[to], to}); } } } cout << D[N - 1] << "\n"; } return 0; }