// Problem: No.2622 Dam // Contest: yukicoder // URL: https://yukicoder.me/problems/no/2622 // Memory Limit: 512 MB // Time Limit: 2000 ms #include #define debug(x) cerr<<(#x)<<" "<<(x)< #define rep(i,a,b) for(ll i=(a);i<=(b);++i) #define per(i,a,b) for(ll i=(a);i>=(b);--i) using namespace std; bool Mbe; ll read(){ ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void write(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)write(x/10); putchar(x%10+'0'); } ll T,X,V,Fo,Fi,R,Q; void solve(){ if(Fo>Fi){ puts("Zero"); return ; } if(Fo==Fi){ if(R==Q-1)puts("Safe"); else puts("Zero"); return ; } ll d1=R*(Fi-Fo); ll d2=-(Q-R)*Fo; if(X+d1<=0){ puts("Zero"); return ; } if(X+d1>V){ puts("Overflow"); return ; } if(d1+d2<0){ puts("Zero"); return ; } if(d1+d2==0){ puts("Safe"); return ; } puts("Overflow"); } bool Med; int main(){ cerr<