Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintWriter;
- /**
- *
- * @author florence
- */
- public class Ursi {
- public char[] charachets = new char[1000];
- public final static String INPUT_FILE = "ursi.in";
- public final static String OUTPUT_FILE = "ursi.out";
- public void readInput() throws FileNotFoundException, IOException{
- int c;
- int i = 0;
- try {
- FileReader inputStream = new FileReader(INPUT_FILE);
- while ((c = inputStream.read()) != -1) {
- charachets[++i] = (char) c;
- }
- if (inputStream != null) {
- inputStream.close();
- }
- } catch(IOException e){
- throw new RuntimeException(e);
- }
- System.out.println(charachets);
- }
- public void writeOutput(int res){
- try {
- PrintWriter pw = new PrintWriter(new File(OUTPUT_FILE));
- if((res % (Math.pow(10, 9) + 7)) % 2 == 1){
- pw.printf("%0\n", 0);
- } else {
- pw.printf("%d\n", (int)(res % (Math.pow(10, 9) + 7)));
- }
- pw.close();
- } catch( IOException e) {
- throw new RuntimeException(e);
- }
- }
- int feteZambarete(){
- int halfsmile = 0;
- for(int i = 0; i < charachets.length; i++){
- if(charachets[i] == '^')
- halfsmile += 1;
- }
- return halfsmile;
- }
- public void solve() throws IOException{
- readInput();
- writeOutput(feteZambarete());
- }
- public static void main(String[] args) throws IOException {
- new Ursi().solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement