记录编号 49976 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 [東方S1] 东风谷早苗 最终得分 100
用户昵称 Gravatarcstdio 是否通过 通过
代码语言 C++ 运行时间 0.008 s
提交时间 2012-11-10 16:00:30 内存使用 0.31 MiB
显示代码纯文本
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<iomanip>
  5. #include<string>
  6. #include<algorithm>
  7. using namespace std;
  8. int main(){
  9. freopen("android.in","r",stdin);
  10. freopen("android.out","w",stdout);
  11. string s;
  12. char ch;
  13. long i=0,x=0,y=0,t,len,p=0,west=0,south=0,east=0,north=0;
  14. cin>>s>>t;
  15. len=s.size();
  16. while(i<len){
  17. ch=s[i];
  18. if(ch=='E') east++;
  19. else if(ch=='S') south++;
  20. else if(ch=='W') west++;
  21. else if(ch=='N') north++;
  22. i++;
  23. }
  24. long temp=t/len;
  25. x+=east*temp,x-=west*temp,y+=north*temp,y-=south*temp;
  26. t%=len,i=0;
  27. while(i<t){
  28. ch=s[i];
  29. if(ch=='E') x++;
  30. else if(ch=='S') y--;
  31. else if(ch=='W') x--;
  32. else if(ch=='N') y++;
  33. i++;
  34. }
  35. printf("%d %d",x,y);
  36. return 0;
  37. }