Advertisement
florence20

Untitled

Apr 14th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.FileReader;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6.  
  7. /**
  8. *
  9. * @author florence
  10. */
  11. public class Ursi {
  12.  
  13. public char[] charachets = new char[1000];
  14.  
  15. public final static String INPUT_FILE = "ursi.in";
  16. public final static String OUTPUT_FILE = "ursi.out";
  17.  
  18. public void readInput() throws FileNotFoundException, IOException{
  19. int c;
  20. int i = 0;
  21.  
  22. try {
  23. FileReader inputStream = new FileReader(INPUT_FILE);
  24. while ((c = inputStream.read()) != -1) {
  25. charachets[++i] = (char) c;
  26. }
  27. if (inputStream != null) {
  28. inputStream.close();
  29. }
  30.  
  31. } catch(IOException e){
  32. throw new RuntimeException(e);
  33. }
  34. System.out.println(charachets);
  35. }
  36.  
  37. public void writeOutput(int res){
  38. try {
  39. PrintWriter pw = new PrintWriter(new File(OUTPUT_FILE));
  40. if((res % (Math.pow(10, 9) + 7)) % 2 == 1){
  41. pw.printf("%0\n", 0);
  42. } else {
  43.  
  44. pw.printf("%d\n", (int)(res % (Math.pow(10, 9) + 7)));
  45. }
  46. pw.close();
  47. } catch( IOException e) {
  48. throw new RuntimeException(e);
  49. }
  50. }
  51.  
  52. int feteZambarete(){
  53. int halfsmile = 0;
  54. for(int i = 0; i < charachets.length; i++){
  55. if(charachets[i] == '^')
  56. halfsmile += 1;
  57. }
  58. return halfsmile;
  59. }
  60.  
  61. public void solve() throws IOException{
  62. readInput();
  63. writeOutput(feteZambarete());
  64. }
  65. public static void main(String[] args) throws IOException {
  66. new Ursi().solve();
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement