Пример #1
0
  public void begin(String[] args) {
    try {

      String output = "";

      BufferedReader bf = new BufferedReader(new FileReader(dir_inputs + "A-large-practice.in"));
      // BufferedReader bf = new BufferedReader(new FileReader(new File (args[0])));

      int T = Integer.parseInt(bf.readLine());

      for (int i = 1; i <= T; ++i) {

        int j;

        int SIZE = Integer.parseInt(bf.readLine());

        long[] data_x = insertion_sort(bf.readLine().split(" "), SIZE, SORT.LESS);
        long[] data_y = insertion_sort(bf.readLine().split(" "), SIZE, SORT.HIGH);

        BigInteger scalar = new BigInteger("0");
        for (j = 0; j < data_x.length; ++j)
          scalar = scalar.add(new BigInteger(Long.toString(data_x[j] * data_y[j])));

        System.out.println("Case #" + i + ": " + scalar);

        output = output + "Case #" + i + ": " + scalar + "\n";
        Files file = new Files(dir_inputs + "output", false);
        file.write(output);
        file.close();
      }

    } catch (IOException e) {
    }
  }
Пример #2
0
 public static void prepareProjectPanel(ProjectPanel panel) {
   BatchPack pack = panel.getProjectBatch();
   if (pack.isLibrary() || pack.isDebugMode()) return;
   AndroidProject project = pack.getAttributes().getAndroidProject();
   ArrayList<String> libPaths = PackManager.getRelativeLibraryPaths(project.projectPath);
   for (String libPath : libPaths) {
     String configer =
         Files.readTextFile(new File(project.projectPath, "project.properties"), true);
     String keyName = new File(libPath).getName();
     String libraryPath = publicLibraries.get(keyName);
     if (libraryPath == null) {
       System.err.println("error: not found dependency library " + keyName);
       continue;
     }
     libraryPath = Files.convert2AbsolutePath("", libraryPath);
     try {
       String relativePath =
           Files.toRelativePath(new File(project.projectPath), new File(libraryPath));
       configer = configer.replace(libPath, relativePath);
       Files.saveTextFile(new File(project.projectPath, "project.properties"), configer);
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
 }
Пример #3
0
 private void syncProjectConfig() {
   if (syncProjectConfigHelper == null) {
     Attributes attributes = new Attributes();
     try {
       attributes.loadFromXML(new FileInputStream("config.xml"));
       if (attributes.containsKey(BatchPack.KEY_ACCOUNT)) {
         attributes.loadFromXML(
             new FileInputStream(
                 Files.convert2AbsolutePath(".", attributes.getProperty(BatchPack.KEY_ACCOUNT))));
       }
       syncProjectConfigHelper =
           new SVNHelper(
               attributes.getProperty("projectConfigUrl"),
               attributes.getProperty("userName"),
               attributes.getProperty("password"));
       int version = records.getProjectVersion(PackRecords.CONFIG_PROJECT_ID);
       if (version != syncProjectConfigHelper.getProjectVersion()) {
         syncProjectConfigHelper.exportProject(new File("projects").getAbsolutePath());
         syncProjectConfigHelper.setProjectUrl(attributes.getProperty("libProjectConfigUrl"));
         syncProjectConfigHelper.exportProject(new File("libProjects").getAbsolutePath());
       }
       records.setProjectVersion(
           PackRecords.CONFIG_PROJECT_ID, syncProjectConfigHelper.getProjectVersion());
       records.saveRecords();
       System.out.println("import latest config ok");
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }