如果你莫名 RE,你需要把
while(true){ cin>>n>>v>>x; if(!n&&!v&&!x) break; ... }
改成:
while(cin>>n>>v>>x){ if(!n&&!v&&!x) break; ... }
毒瘤 UVA!